Opened 6 years ago

Last modified 6 years ago

#26186 closed Bug

When extending from abstract model, ForeignKey points to wrong application — at Version 3

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 skyjur)

This might be related to

I have following code:


class AbstractModel1(Model):
    class Meta:
        abstract = True

class AbstractModel2(Model):
    model1 = ForeignKey('Model1')

    class Meta:
          abstract = True


from .abstract import AbstractModel1, AbstractModel12

class Model1(AbstractModel1):

class Model2(AbstractModel12):


from app_A.abstract import AbstractModel1, AbstractModel2

class Model1(AbstractModel1):

class Model2(AbstractModel12):

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:

Change History (3)

comment:1 Changed 6 years ago by Simon Charette

Resolution: invalid
Status: newclosed

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' in INSTALLED_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.

comment:2 Changed 6 years ago by skyjur

I have updated your test case:

In my app my abstract models are defined in a/ and then imported into a/, I didn't realise this was important.

comment:3 Changed 6 years ago by skyjur

Description: modified (diff)
Resolution: invalid
Status: closednew
Note: See TracTickets for help on using tickets.
Back to Top