Imagine I have a model called A
, which has a field called name
. How can I get previous value and new value in pre_save
signal?
@receiver(pre_save, sender=A)
def signal_product_manage_latest_version_id(
sender, instance, update_fields=None, **kwargs):
if 'name' in update_fields:
print(instance.name)
Will the name
be the old value or the new value when I call the following?
a = A.objects.create(name="John")
a.name = "Lee"
a.save()
objects.get
will cause exception. – Overlying