Skip to content

Commit

Permalink
Add documentation about the option excluded_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
joaojunior committed May 11, 2017
1 parent 15fd9e2 commit 3ffe151
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,29 @@ You can use the ``table_name`` parameter with both ``HistoricalRecords()`` or
pub_date = models.DateTimeField('date published')
register(Question, table_name='polls_question_history')
Choosing fields to not be stored
--------------------------------

It is possible to use the parameter `excluded_fields` to choice which fields
will be stored on every create/update/delete.

For example, if you have the model:

.. code-block:: python
class PollWithExcludeFields(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
And you don't want to stored the changes for the field `pub_date`, it is necessary to update the model to:

.. code-block:: python
class PollWithExcludeFields(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
history = HistoricalRecords(excluded_fields=['pub_date'])
By default, django-simple-history stores the changes for all fields in the model.

0 comments on commit 3ffe151

Please sign in to comment.