5

what happens when we use "on_delete=models.CASCADE" in django models

class HospitalStay(models.Model):

    patient = models.ForeignKey(User, on_delete = models.CASCADE)
1

1 Answer 1

16

CASCADE means that the row will be deleted too if the ForeignKey gets deleted.

In your case, HospitalStay instance will be deleted if the User Linked to it gets deleted.

Read more on django docs

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.