from django.db.models.signals import post_save, post_delete from django.dispatch import receiver from django.db import transaction from .models import MT002HModel @receiver(post_save, sender=MT002HModel) @receiver(post_delete, sender=MT002HModel) @transaction.atomic def mt002h_save_delete(sender, instance, created, **kwargs): if created: print(f"Instance {instance} was saved.") # Handle post_save logic here else: print(f"Instance {instance} was deleted.") # Handle post_delete logic here
标签:MT002HModel,删除,django,合用,import,post,save,delete From: https://www.cnblogs.com/beichengshiqiao/p/17840111.html