You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+11-14Lines changed: 11 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,39 +2,36 @@
2
2
django-model-changes
3
3
====================
4
4
5
-
Please note: django-model-changes does not support Python3.0+. A fork is maintained at https://github.com/iansprice/django-model-changes-py3 for Python3.3+ and can be installed via `pip install django-model-changes-py3`.
5
+
django-model-changes allows you to track the state and changes of a model instance.
6
6
7
-
django-model-changes allows you to track the state and changes of a model instance:
7
+
**Requirements:** Python 3.14+, Django 5.0-6.x
8
8
9
9
Quick start
10
10
-----------
11
11
12
12
1. Install django-model-changes::
13
13
14
-
pip install django-model-changes
14
+
uv add django-model-changes
15
15
16
-
2. Add "django_model_changes" to your INSTALLED_APPS setting like this::
16
+
Or with pip::
17
17
18
-
INSTALLED_APPS = (
19
-
...
20
-
'django_model_changes',
21
-
)
18
+
pip install django-model-changes
22
19
23
-
3. Add the `ChangesMixin` to your model::
20
+
2. Add the ``ChangesMixin`` to your model::
24
21
25
22
>>> from django.db import models
26
23
>>> from django_model_changes import ChangesMixin
27
24
28
25
>>> class User(ChangesMixin, models.Model):
29
26
>>> name = models.CharField(max_length=100)
30
27
31
-
4. Get instance changes::
28
+
3. Get instance changes::
32
29
33
30
>>> user = User()
34
31
>>> user.name = 'Foo Bar'
35
32
>>> user.save()
36
33
37
-
>>> user.name 'I got a new name'
34
+
>>> user.name = 'I got a new name'
38
35
39
36
>>> # Get current state
40
37
>>> user.current_state()
@@ -64,10 +61,10 @@ Quick start
64
61
>>> user.is_persisted()
65
62
True
66
63
67
-
5. Listen for changes::
68
-
64
+
4. Listen for changes::
65
+
69
66
>>> from django_model_changes import post_change
70
-
67
+
71
68
>>> def my_callback(sender, instance, **kwargs):
72
69
>>> # Do something with previous and current state
0 commit comments