Skip to content

Commit 7522cb9

Browse files
committed
Documentation for table_name parameter.
1 parent 15a5699 commit 7522cb9

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changes
44
tip (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

89
1.6.3 (2015-07-30)
910
------------------

docs/advanced.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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')

0 commit comments

Comments
 (0)