[Django] #24867: admin.E202 seems to include superclass references?

11 views
Skip to first unread message

Django

unread,
May 28, 2015, 4:01:26 AM5/28/15
to django-...@googlegroups.com
#24867: admin.E202 seems to include superclass references?
---------------------------------+------------------------
Reporter: TorstenRottmann | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Keywords: admin.E202
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------
I have this three models defined:

{{{
class Act(models.Model):
....

class Form(Act):
...

class Diagnosis(Act):
form = models.ForeignKey(Form)

}}}

...and this admin.py:
{{{
class DiagnosisInline(admin.TabularInline):
model = Diagnosis
...

class FormAdmin(admin.ModelAdmin):
....
inlines = [DiagnosisInline]

admin.site.register(Form, FormAdmin)
}}}

This triggers 'admin.E202':
{{{
<class 'nm.admin.DiagnosisInline'>: (admin.E202) 'nm.Diagnosis' has more
than one ForeignKey to 'nm.Form'
}}}

Without looking into the source for this system check, I guess, that it
counts all possible references, that lead to the admin class, the inline
is included in.

And it counts two, from which one is right (Form) and one is wrong (Act),
because it's already it's own superclass reference.

Am I right?

--
Ticket URL: <https://code.djangoproject.com/ticket/24867>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 28, 2015, 9:14:36 AM5/28/15
to django-...@googlegroups.com
#24867: admin.E202 seems to include superclass references?
---------------------------------+--------------------------------------
Reporter: TorstenRottmann | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution: invalid

Keywords: admin.E202 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_docs: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

There's no need to have the foreign key on `Diagnosis` as that model has
an automatically created `OneToOneField` to `Form` because your models use
[https://docs.djangoproject.com/en/stable/topics/db/models/#multi-table-
inheritance multi-table inheritance].

--
Ticket URL: <https://code.djangoproject.com/ticket/24867#comment:1>

Django

unread,
May 29, 2015, 5:12:53 AM5/29/15
to django-...@googlegroups.com
#24867: admin.E202 seems to include superclass references?
---------------------------------+--------------------------------------
Reporter: TorstenRottmann | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution: invalid

Keywords: admin.E202 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by TorstenRottmann):

Well, that doesn't work. The inlines should be the {{{Diagnosis}}}, that
point to a {{{Form}}} – and I simply can't manage that to work.
How is that done?

--
Ticket URL: <https://code.djangoproject.com/ticket/24867#comment:2>

Django

unread,
May 29, 2015, 5:13:06 AM5/29/15
to django-...@googlegroups.com
#24867: admin.E202 seems to include superclass references?
---------------------------------+--------------------------------------

Reporter: TorstenRottmann | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution:

Keywords: admin.E202 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by TorstenRottmann):

* status: closed => new
* resolution: invalid =>


--
Ticket URL: <https://code.djangoproject.com/ticket/24867#comment:3>

Django

unread,
May 29, 2015, 7:06:40 AM5/29/15
to django-...@googlegroups.com
#24867: admin.E202 seems to include superclass references?
---------------------------------+--------------------------------------
Reporter: TorstenRottmann | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.7
Severity: Normal | Resolution: invalid

Keywords: admin.E202 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed

* resolution: => invalid


Comment:

Maybe what you meant to do is make Act an
[https://docs.djangoproject.com/en/stable/topics/db/models/#abstract-base-
classes abstract base model]. In that case, your original code should work
fine.

For future reference, "is it a bug" type questions should be directed to
our support channels at TicketClosingReasons/UseSupportChannels. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/24867#comment:4>

Reply all
Reply to author
Forward
0 new messages