Skip to content

Commit 3179eaf

Browse files
committed
Add documentation about the option excluded_fields
1 parent 15fd9e2 commit 3179eaf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/advanced.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,29 @@ You can use the ``table_name`` parameter with both ``HistoricalRecords()`` or
213213
pub_date = models.DateTimeField('date published')
214214
215215
register(Question, table_name='polls_question_history')
216+
217+
Choosing fields to not be stored
218+
--------------------------------
219+
220+
It is possible to use the parameter ``excluded_fields`` to choice which fields
221+
will be stored on every create/update/delete.
222+
223+
For example, if you have the model:
224+
225+
.. code-block:: python
226+
227+
class PollWithExcludeFields(models.Model):
228+
question = models.CharField(max_length=200)
229+
pub_date = models.DateTimeField('date published')
230+
231+
And you don't want to stored the changes for the field ``pub_date``, it is necessary to update the model to:
232+
233+
.. code-block:: python
234+
235+
class PollWithExcludeFields(models.Model):
236+
question = models.CharField(max_length=200)
237+
pub_date = models.DateTimeField('date published')
238+
239+
history = HistoricalRecords(excluded_fields=['pub_date'])
240+
241+
By default, django-simple-history stores the changes for all fields in the model.

0 commit comments

Comments
 (0)