#28110: Model inheritance mistakenly associates child fields with parent (when
running checks)
-------------------------------------+-------------------------------------
Reporter: Matthew | Owner: nobody
Schinckel |
Type: Bug | Status: new
Component: Database | Version: 1.11
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have a model structure that generates a `models.E006` error under Django
1.9 onwards:
{{{
from django.db import models
class OrgUnit(models.Model):
name = models.CharField(max_length=128)
class Organisation(OrgUnit):
config = models.TextField(default='{}')
class Region(OrgUnit):
organisation = models.ForeignKey(Organisation, related_name='regions')
class SubRegion(OrgUnit):
region = models.ForeignKey(Region, related_name='sub_regions')
}}}
When running `./manage.py check`, this results in:
{{{
SystemCheckError: System check identified some issues:
ERRORS:
org.Region.organisation: (models.E006) The field 'organisation' clashes
with the field 'organisation' from model 'org.orgunit'.
org.SubRegion.region: (models.E006) The field 'region' clashes with the
field 'region' from model 'org.orgunit'.
System check identified 2 issues (0 silenced).
}}}
However, I believe these are incorrect: the model OrgUnit does not have
the fields listed.
This model structure worked fine in 1.8, but started failing in 1.9 (and
still fails under 1.11).
I have a repository containing a minimal project at
https://bitbucket.org/schinckel/inheritance-test
--
Ticket URL: <https://code.djangoproject.com/ticket/28110>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.169dab261f88b90bf142e14e755ae790%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.