Skip to content

Commit

Permalink
More docs suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ddabble committed Jun 7, 2024
1 parent 2581d13 commit 9df1bc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions docs/querying_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,11 @@ model history.
<Poll: Poll object as of 2010-10-25 18:04:13.814128>
Save Without Creating Historical Records
Save without creating historical records
----------------------------------------

If you want to save model objects without triggering the creation of any historical
records, you can set a ``skip_history_when_saving`` attribute to ``True``
on each object before saving - for example like this:
records, you can do the following:

.. code-block:: python
Expand All @@ -189,7 +188,7 @@ on each object before saving - for example like this:
# We recommend deleting the attribute afterward
del poll.skip_history_when_saving
This also works when creating an object, but only when calling the ``save`` method:
This also works when creating an object, but only when calling ``save()``:

.. code-block:: python
Expand All @@ -199,6 +198,9 @@ This also works when creating an object, but only when calling the ``save`` meth
poll.save()
del poll.skip_history_when_saving
.. note::
Historical records will always be created when calling the ``create()`` manager method.

Alternatively, call the ``save_without_historical_record()`` method on each object
instead of ``save()``.
This method is automatically added to a model when registering it for history-tracking
Expand Down
2 changes: 1 addition & 1 deletion simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def save_without_historical_record(self, *args, **kwargs):
"""
Save the model instance without creating a historical record.
*Make sure you know what you're doing before using this method.*
Make sure you know what you're doing before using this method.
"""
self.skip_history_when_saving = True
try:
Expand Down

0 comments on commit 9df1bc3

Please sign in to comment.