Skip to content

Commit 038da8f

Browse files
committed
Render code block properly [issue 293]
The code block in the documentation on saving an instance without an historical record now actually renders.
1 parent a1f54db commit 038da8f

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

docs/advanced.rst

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -280,31 +280,25 @@ Or you can pass the change reason explicitly:
280280
poll.save()
281281
update_change_reason(poll, 'Add a question')
282282
283-
Save Without Historical Record
284-
------------------------------
283+
Save without a historical record
284+
--------------------------------
285285

286-
You want save model without saving a historical record. You can use this method.
286+
If you want to save a model without a historical record, you can use the following:
287287

288288
.. code-block:: python
289-
def save_without_historical_record(self, *args, **kwargs):
290-
self.skip_history_when_saving = True
291-
try:
292-
ret = self.save(*args, **kwargs)
293-
finally:
294-
del self.skip_history_when_saving
295-
return ret
296-
297289
298-
.. code-block:: python
299290
class Poll(models.Model):
300291
question = models.CharField(max_length=200)
301292
history = HistoricalRecords()
302293
303-
304-
.. code-block:: python
305-
poll = Poll(quetions='somthing')
306-
poll.save_without_historical_record()
307-
308-
294+
def save_without_historical_record(self, *args, **kwargs):
295+
self.skip_history_when_saving = True
296+
try:
297+
ret = self.save(*args, **kwargs)
298+
finally:
299+
del self.skip_history_when_saving
300+
return ret
309301
310302
303+
poll = Poll(question='something')
304+
poll.save_without_historical_record()

0 commit comments

Comments
 (0)