Opened 9 years ago
Last modified 9 years ago
#26186 closed Bug
When extending from abstract model, ForeignKey points to wrong application — at Version 4
Reported by: | skyjur | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.9 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
This might be related to https://code.djangoproject.com/ticket/25858
I have following code:
app_A/abstract.py:
class AbstractModel1(Model): class Meta: abstract = True class AbstractModel2(Model): model1 = ForeignKey('Model1') class Meta: abstract = True
app_A/models.py:
from .abstract import AbstractModel1, AbstractModel12 class Model1(AbstractModel1): pass class Model2(AbstractModel12): pass
app_B/models.py:
from app_A.abstract import AbstractModel1, AbstractModel2 class Model1(AbstractModel1): pass class Model2(AbstractModel12): pass
in Django 1.8, the app_B.Model2.model1
would point to app_B.Model1
, but in Django 1.9.2 it points to app_A.Model1
so my code no longer works.
Test case can be found: https://github.com/skyjur/django-ticketing/tree/master/ticket_26186
Change History (4)
comment:1 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 9 years ago
I have updated your test case:
https://github.com/charettes/django-ticketing/pull/1
In my app my abstract models are defined in a/abstract.py
and then imported into a/models.py
, I didn't realise this was important.
comment:3 by , 9 years ago
Description: | modified (diff) |
---|---|
Resolution: | invalid |
Status: | closed → new |
comment:4 by , 9 years ago
Description: | modified (diff) |
---|
Hi skyjur,
While I can reproduce on Django 1.9 and 1.9.1 (where it was considered a regression #25858) I cannot reproduce on any version of Django 1.8.
I even tried swapping the order of
'app_A'
and'app_B'
inINSTALLED_APPS
with no success.You can find the test applications I used in my attempts to reproduce here.
Are you sure you managed to reproduce against Django 1.8? If it's the case please reopen this ticket with more details.