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
15
15
- Joao Pedro Francese
16
16
- jofusa
17
17
- John Whitlock
18
+ - Jonathan Leroy
18
19
- Jonathan Sanchez
19
20
- Josh Fyne
20
21
- Klaas van Schelven
Original file line number Diff line number Diff line change 4
4
tip (unreleased)
5
5
----------------
6
6
- Add ability to list history in admin when the object instance is deleted. (gh-72)
7
+ - Support for custom tables names (gh-196)
7
8
8
9
1.6.3 (2015-07-30)
9
10
------------------
Original file line number Diff line number Diff line change @@ -158,3 +158,29 @@ To change the auto-generated HistoricalRecord models base class from
158
158
pub_date = models.DateTimeField(' date published' )
159
159
changed_by = models.ForeignKey(' auth.User' )
160
160
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