File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ Authors
1515- Joao Pedro Francese
1616- jofusa
1717- John Whitlock
18+ - Jonathan Leroy
1819- Jonathan Sanchez
1920- Josh Fyne
2021- Klaas van Schelven
Original file line number Diff line number Diff line change 44tip (unreleased)
55----------------
66- Add ability to list history in admin when the object instance is deleted. (gh-72)
7+ - Support for custom tables names (gh-196)
78
891.6.3 (2015-07-30)
910------------------
Original file line number Diff line number Diff line change @@ -158,3 +158,29 @@ To change the auto-generated HistoricalRecord models base class from
158158 pub_date = models.DateTimeField(' date published' )
159159 changed_by = models.ForeignKey(' auth.User' )
160160 history = HistoricalRecords(bases = [RoutableModel])
161+
162+ Custom history table name
163+ -------------------------
164+
165+ By default, the table name for historical models follow the Django convention
166+ and just add ``historical `` before model name. For instance, if your application
167+ name is ``polls `` and your model name ``Question ``, then the table name will be
168+ ``polls_historicalquestion ``.
169+
170+ You can use the ``table_name `` parameter with both ``HistoricalRecords() `` or
171+ ``register() `` to change this behavior.
172+
173+ .. code-block :: python
174+
175+ class Question (models .Model ):
176+ question_text = models.CharField(max_length = 200 )
177+ pub_date = models.DateTimeField(' date published' )
178+ history = HistoricalRecords(table_name = ' polls_question_history' )
179+
180+ .. code-block :: python
181+
182+ class Question (models .Model ):
183+ question_text = models.CharField(max_length = 200 )
184+ pub_date = models.DateTimeField(' date published' )
185+
186+ register(Question, table_name = ' polls_question_history' )
You can’t perform that action at this time.
0 commit comments