Docs update: has_changed supports a single field

Closes #225
This commit is contained in:
Daniel Stanton 2016-07-13 17:57:13 +01:00 committed by GitHub
parent ce6bc45963
commit 98416539a5

View file

@ -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.