Skip to content

Commit 806d1d1

Browse files
author
Ross Mechanic
authored
Added documentation about the different ways to record which user changed a model (#376)
1 parent fd2bbb8 commit 806d1d1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/advanced.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ inheriting from them to have historical tracking as well.
9898
9999
Recording Which User Changed a Model
100100
------------------------------------
101+
There are three documented ways to attach users to a tracked change:
102+
103+
1. Use the middleware as described in :doc:`/usage`. The middleware sets the
104+
User instance that made the request as the ``history_user`` on the history
105+
table.
106+
107+
2. Use ``simple_history.admin.SimpleHistoryAdmin`. Under the hood,
108+
``SimpleHistoryAdmin`` actually sets the ``_history_user`` on the object to
109+
attach the user to the tracked change by overriding the `save_model` method.
110+
111+
3. Assign a user to the ``_history_user`` attribute of the object as described
112+
below:
113+
114+
Using ``_history_user`` to Record Which User Changed a Model
115+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101116

102117
To denote which user changed a model, assign a ``_history_user`` attribute on
103118
your model.

0 commit comments

Comments
 (0)