Delete Record Before Save

时间:2019-01-07 13:01:46

标签: django django-models django-forms django-templates django-views

i want to delete all the records which having the company.id in model AclRoleAccess

AclRoleAccess(models.Model):
    acl_role = models.ForeignKey(ACLRoles, on_delete=models.CASCADE)
    acl_company = models.ForeignKey(Company, on_delete=models.CASCADE)
    acl_functionality = models.ForeignKey(AclFunctionality, on_delete=models.CASCADE)
    acl_has_access = models.BooleanField()

    class Meta:
        db_table = "acl_role_accesses"


@receiver(pre_save, sender=AclRoleAccess)
def delete_AclRoleAccess(sender, instance, update_fields=None, **kwargs):
    print('Delete These', instance)

0 个答案:

没有答案