1
- Usage
2
- =====
1
+ Quick Start
2
+ ===========
3
3
4
4
Install
5
5
-------
@@ -16,10 +16,37 @@ Install from PyPI with ``pip``:
16
16
.. _crate.io : https://crate.io/packages/django-simple-history/
17
17
18
18
19
- Quickstart
20
- ----------
19
+ Configure
20
+ ---------
21
21
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
+ ~~~~~~
23
50
24
51
To track history for a model, create an instance of
25
52
``simple_history.models.HistoricalRecords `` on the model.
@@ -46,20 +73,8 @@ Django tutorial:
46
73
Now all changes to ``Poll `` and ``Choice `` model instances will be tracked in
47
74
the database.
48
75
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
+ ~~~~~~~~~~~~~~~~~
63
78
64
79
For existing projects, you can call the populate command to generate an
65
80
initial change for preexisting model instances:
@@ -153,4 +168,3 @@ records for all ``Choice`` instances can be queried by using the manager on the
153
168
<simple_history.manager.HistoryManager object at 0x1cc4290>
154
169
>>> Choice.history.all()
155
170
[<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