This is a lengthy syntax question.

Asked 2 years ago, Updated 2 years ago, 42 views

Hello, everyone ^ I'm asking you a question because there's a blockage during study as an official document of Jango. 1.9 In the N:1 data field definition, it is defined as ForeignKey followed by (self, on_delete=models.CASCADE). I wonder what the on_delete=models.CASCADE syntax does. I looked it up, but I don't know ㅠ<

^

django

2022-09-22 11:00

1 Answers

When Model A and Model B have an N:1 relationship, if Model A has the on_delete=models.CASADE syntax set, if any record in Model B is deleted, the records in Model A related to the record in Model B to be deleted are also deleted annually.

If on_delete is not set, it cannot be deleted because there are records from other models that reference the records from model B.

You can think of CASCADE as having the same effect (behavior) on a model that is not directly directed to do something, but that it has the same effect (behavior


2022-09-22 11:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.