File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 11Changes
22=======
33
4+ tip (unreleased)
5+ ----------------
6+ - History tracking can be inherited by passing `inherit=True `. (gh-63)
7+
481.7.0 (2015-12-02)
59------------------
610- Add ability to list history in admin when the object instance is deleted. (gh-72)
Original file line number Diff line number Diff line change @@ -65,6 +65,35 @@ third-party apps you don't have control over. Here's an example of using
6565 register(User)
6666
6767
68+ Allow tracking to be inherited
69+ ---------------------------------
70+
71+ By default history tracking is only added for the model that is passed
72+ to ``register() `` or has the ``HistoricalRecords `` descriptor. By
73+ passing ``inherit=True `` to either way of registering you can change
74+ that behavior so that any child model inheriting from it will have
75+ historical tracking as well. Be careful though, in cases where a model
76+ can be tracked more than once, ``MultipleRegistrationsError `` will be
77+ raised.
78+
79+ .. code-block :: python
80+
81+ from django.contrib.auth.models import User
82+ from django.db import models
83+ from simple_history import register
84+ from simple_history.models import HistoricalRecords
85+
86+ # register() example
87+ register(User, inherit = True )
88+
89+ # HistoricalRecords example
90+ class Poll (models .Model ):
91+ history = HistoricalRecords(inherit = True )
92+
93+ Both ``User `` and ``Poll `` in the example above will cause any model
94+ inheriting from them to have historical tracking as well.
95+
96+
6897.. recording_user:
6998
7099 Recording Which User Changed a Model
You can’t perform that action at this time.
0 commit comments