Skip to content

Commit 158ee65

Browse files
committed
Merge pull request #144 from treyhunner/documentation
Update Documentation
2 parents e9bf1a8 + 110ec14 commit 158ee65

File tree

5 files changed

+75
-29
lines changed

5 files changed

+75
-29
lines changed

doc-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sphinx==1.2.3
2+
sphinx-autobuild==0.3.0

docs/advanced.rst

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
Advanced Usage
22
==============
33

4-
Version-controlling with South
5-
------------------------------
4+
Database Migrations
5+
-------------------
66

7-
By default, Historical models live in the same app as the model they track.
8-
Historical models are tracked by South in the same way as any other model.
9-
Whenever the original model changes, the historical model will change also.
7+
By default, Historical models live in the same app as the model they
8+
track. Historical models are tracked by migrations in the same way as
9+
any other model. Whenever the original model changes, the historical
10+
model will change also.
1011

11-
Therefore tracking historical models with South should work automatically.
12+
Therefore tracking historical models with migrations should work
13+
automatically.
1214

1315

1416
Locating past model instance
@@ -44,8 +46,10 @@ model history.
4446
<Poll: Poll object as of 2010-10-25 18:04:13.814128>
4547
4648
47-
History for Third-Party Model
48-
-----------------------------
49+
.. _register:
50+
51+
History for a Third-Party Model
52+
-------------------------------
4953

5054
To track history for a model you didn't create, use the
5155
``simple_history.register`` utility. You can use this to track models from
@@ -61,7 +65,7 @@ third-party apps you don't have control over. Here's an example of using
6165
register(User)
6266
6367
64-
.. _recording_user:
68+
.. recording_user:
6569
6670
Recording Which User Changed a Model
6771
------------------------------------

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Documentation
1010
:maxdepth: 2
1111

1212
usage
13+
reference
1314
advanced
1415

1516
Code

docs/reference.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Common Issues
2+
=============
3+
4+
- ``fields.E300``::
5+
6+
ERRORS:
7+
custom_user.HistoricalCustomUser.history_user: (fields.E300) Field defines a relation with model 'custom_user.CustomUser', which is either not installed, or is abstract.
8+
9+
Use ``register()`` to track changes to the custom user model
10+
instead of setting ``HistoricalRecords`` on the model directly.
11+
See :ref:`register`.
12+
13+
The reason for this, is that unfortunately ``HistoricalRecords``
14+
cannot be set directly on a swapped user model because of the user
15+
foreign key to track the user making changes.
16+
17+
- ``HistoricalRecords`` is not inherited
18+
19+
Allowing ``HistoricalRecords`` to be inherited from abstract
20+
models or other parents is a feature we would love to add. The
21+
current contributors do not have a need for that feature at this
22+
point, and need some help understanding how this feature should be
23+
completed. Current work is in `#112`__.
24+
25+
__ https://github.com/treyhunner/django-simple-history/pull/112

docs/usage.rst

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Usage
2-
=====
1+
Quick Start
2+
===========
33

44
Install
55
-------
@@ -16,10 +16,37 @@ Install from PyPI with ``pip``:
1616
.. _crate.io: https://crate.io/packages/django-simple-history/
1717

1818

19-
Quickstart
20-
----------
19+
Configure
20+
---------
2121

22-
Add ``simple_history`` to your ``INSTALLED_APPS``.
22+
Settings
23+
~~~~~~~~
24+
25+
Add ``simple_history`` to your ``INSTALLED_APPS``
26+
27+
.. code-block:: python
28+
29+
INSTALLED_APPS = [
30+
# ...
31+
'simple_history',
32+
]
33+
34+
The historical models can track who made each change. To populate the
35+
history user automatically you can add middleware to your Django
36+
settings:
37+
38+
.. code-block:: python
39+
40+
MIDDLEWARE_CLASSES = [
41+
# ...
42+
'simple_history.middleware.HistoryRequestMiddleware',
43+
]
44+
45+
If you do not want to use the middleware, you can explicitly indicate
46+
the user making the change as documented in :ref:`recording_user`.
47+
48+
Models
49+
~~~~~~
2350

2451
To track history for a model, create an instance of
2552
``simple_history.models.HistoricalRecords`` on the model.
@@ -46,20 +73,8 @@ Django tutorial:
4673
Now all changes to ``Poll`` and ``Choice`` model instances will be tracked in
4774
the database.
4875

49-
The historical models can also track who made each change. To populate
50-
the history user automatically you can add middleware to your Django
51-
settings:
52-
53-
.. code-block:: python
54-
55-
MIDDLEWARE_CLASSES = [
56-
# ...
57-
'simple_history.middleware.HistoryRequestMiddleware',
58-
]
59-
60-
If you do not want to use the middleware, you can explicitly indicate
61-
the user making the change as indicated in the advanced usage
62-
documentation.
76+
Existing Projects
77+
~~~~~~~~~~~~~~~~~
6378

6479
For existing projects, you can call the populate command to generate an
6580
initial change for preexisting model instances:
@@ -153,4 +168,3 @@ records for all ``Choice`` instances can be queried by using the manager on the
153168
<simple_history.manager.HistoryManager object at 0x1cc4290>
154169
>>> Choice.history.all()
155170
[<HistoricalChoice: Choice object as of 2010-10-25 18:05:12.183340>, <HistoricalChoice: Choice object as of 2010-10-25 18:04:59.047351>]
156-

0 commit comments

Comments
 (0)