Identify the changed fields in django post_save signal
<p>I'm using django's post_save signal to execute some statements after saving the model.</p>

<pre><code>class Mode(models.Model):
    name = models.CharField(max_length=5)
    mode = models.BooleanField()


from django.db.models.signals import post_save
from django.dispatch import receiver

@receiver(post_save, sender=Mode)
def post_save(sender, instance, created, **kwargs):
        # do some stuff
        pass
</code></pre>

<p>Now I want to execute a statement based on whether the value of the <code>mode</code> field has changed or not.</p>

<pre><code>@receiver(post_save, sender=Mode)
def post_save(sender, instance, created, **kwargs):
        # if value of `mode` has changed:
        #  then do this
        # else:
        #  do that
        pass
</code></pre>

<p>I looked at a few SOF threads and a blog but couldn't find a solution to this. All of them were trying to use the pre_save method or form which are not my use case. <a href="https://docs.djangoproject.com/es/1.9/ref/signals/#post-save" rel="noreferrer">https://docs.djangoproject.com/es/1.9/ref/signals/#post-save</a> in the  django docs doesn't mention a direct way to do this.</p>

<p>An answer in the link below looks promising but I don't know how to use it. I'm not sure if the latest django version supports it or not, because I used <code>ipdb</code> to debug this and found that the <code>instance</code> variable has no attribute <code>has_changed</code> as mentioned in the below answer.</p>

<p><a href="https://stackoverflow.com/questions/1355150/django-when-saving-how-can-you-check-if-a-field-has-changed/28094442#28094442">Django: When saving, how can you check if a field has changed?</a></p>