class Leave(models.Model): employee_ID = models.CharField(max_length = 20) name = models.CharField(max_length = 50) user = models.ForeignKey(User, on_delete = models.CASCADE, null =True)def create_form(sender, instance, created, **kwargs): print('form sent')post_save.connect(receiver = create_form, sender= Leave)我已经post_save为我的模型编写了一个信号,因此每次ModelForm保存它时都会打印它form sent,但是如果我更改/adminand 中的某些字段,也会发生同样的情况save。signal如果管理员更改了任何字段,我该如何停止并编写另一个。我已经为管理员尝试过这个,但它不起作用from django.contrib import admindef admin_alter(sender, instance, created, **kwargs): if Leave.status == '1': print('admin altered')post_save.connect(receiver = after_accepting, sender= admin)
添加回答
举报
0/150
提交
取消