mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-17 04:10:24 +00:00
parent
ce6bc45963
commit
98416539a5
1 changed files with 11 additions and 0 deletions
|
|
@ -164,6 +164,17 @@ Returns ``True`` if the given field has changed since the last save:
|
|||
>>> a.tracker.has_changed('body')
|
||||
False
|
||||
|
||||
The ``has_changed`` method expects a single field. To check multiple fields:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> a = Post.objects.create(title='First Post', description='First Description')
|
||||
>>> a.title = 'Welcome'
|
||||
>>> any(a.tracker.has_changed(field) for field in ('title', 'description')):
|
||||
True
|
||||
>>> all(a.tracker.has_changed(field) for field in ('title', 'description')):
|
||||
False
|
||||
|
||||
The ``has_changed`` method relies on ``previous`` to determine whether a
|
||||
field's values has changed.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue