Skip to content

Commit eaab681

Browse files
authored
Merge pull request #286 from lee-seul/master
added save_without_historical_record to documents
2 parents 8b62857 + 081c04a commit eaab681

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/advanced.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,32 @@ Or you can pass the change reason explicitly:
279279
poll = Poll(question='Question 1')
280280
poll.save()
281281
update_change_reason(poll, 'Add a question')
282+
283+
Save Without Historical Record
284+
------------------------------
285+
286+
You want save model without saving a historical record. You can use this method.
287+
288+
.. 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+
297+
298+
.. code-block:: python
299+
class Poll(models.Model):
300+
question = models.CharField(max_length=200)
301+
history = HistoricalRecords()
302+
303+
304+
.. code-block:: python
305+
poll = Poll(quetions='somthing')
306+
poll.save_without_historical_record()
307+
308+
309+
310+

0 commit comments

Comments
 (0)