How To Execute Cascade On Delete?
I have this model in Django, where a person has the same information from the user provided by Django plus a little bit more information. When I create a new person it requires to
Solution 1:
Try to override the delete method on the model (code not tested):
classPerson(models.Model):
user = OneToOneField(User)
gender = CharField(max_length=1, choices=GenderChoices, blank=True, null=True)
birth_date = DateField(blank=True, null=True)
def__unicode__(self):
return self.user.username
defdelete():
theuser = User.objects.get(id=user)
theuser.delete()
I have found some relevant documentation about CASCADE usage in Django here.
Post a Comment for "How To Execute Cascade On Delete?"