Skip to content

Commit 85758ec

Browse files
ncvcRoss Mechanic
authored andcommitted
Added ulti-table inheritance docs (#559)
1 parent 6d2f88e commit 85758ec

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/common_issues.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,30 @@ So if we have:
156156
157157
the ``instance`` field will not actually be tracked on the history table because it's
158158
in the reserved set of terms.
159+
160+
Multi-table Inheritance
161+
-----------------------
162+
163+
``django-simple-history`` supports tracking history on models that use multi-table
164+
inheritance, such as:
165+
166+
.. code-block:: python
167+
168+
class ParentModel(models.Model):
169+
parent_field = models.CharField(max_length=255)
170+
history = HistoricalRecords()
171+
172+
class ChildModel(ParentModel):
173+
child_field = models.CharField(max_length=255)
174+
history = HistoricalRecords()
175+
176+
177+
A few notes:
178+
179+
- On the child model, the ``HistoricalRecords`` instance is not inherited from the parent
180+
model. This means that you can choose to track changes on just the parent model, just
181+
the child model, or both.
182+
- The child's history table contains all fields from the child model as well as all the
183+
fields from the parent model.
184+
- Updating a child instance only updates the child's history table, not the parent's
185+
history table.

0 commit comments

Comments
 (0)