Answers for "django pre_save get old instance"

0

django pre_save get old instance

@receiver(pre_save, sender=A)
def signal_product_manage_latest_version_id(sender, instance, update_fields=None, **kwargs):
    try:
        old_instance = A.objects.get(id=instance.id)
    except A.DoesNotExist:  # to handle initial object creation
        return None  # just exiting from signal
    # your code to with 'old_instance'
Posted by: Guest on January-21-2021

Code answers related to "django pre_save get old instance"

Python Answers by Framework

Browse Popular Code Answers by Language