📜  django pre_save 获取旧实例 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:23.645000             🧑  作者: Mango

代码示例1
@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'