Opened 7 years ago
Last modified 4 months ago
#29574 new Bug
Django Foreign Key Mismatch — at Initial Version
Reported by: | josephbiko | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | josephbiko | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Pull Requests: | |||
Description ¶
Django Foreign key's do not track the models DB when the model is inherited from abstract class.
class A(Model): class Meta: abstract = True class B(A): pass class C(Model): fk = foreignkey(B,on_delete=models.CASCADE)
now model B is in table 1 and C points to table 1.
class A(Model): pass class B(A): pass class C(Model): fk = foreignkey(B,on_delete=models.CASCADE)
Now Model B is in table 2 with Model A, however C is still pointing to table 1, which leads to a foreign key mismatch error when you try to add an instance of B
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Note:
See TracTickets
for help on using tickets.