From 98416539a58790bfb74af9d926ff4ba0d369bd02 Mon Sep 17 00:00:00 2001 From: Daniel Stanton Date: Wed, 13 Jul 2016 17:57:13 +0100 Subject: [PATCH] Docs update: has_changed supports a single field Closes #225 --- docs/utilities.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/utilities.rst b/docs/utilities.rst index e8d22d2..9a25061 100644 --- a/docs/utilities.rst +++ b/docs/utilities.rst @@ -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.