[Django] #30273: ModelAdmin for proxy model with InlineModelAdmin for superclass reference results in admin.E202

4 views
Skip to first unread message

Django

unread,
Mar 20, 2019, 11:12:23 AM3/20/19
to django-...@googlegroups.com
#30273: ModelAdmin for proxy model with InlineModelAdmin for superclass reference
results in admin.E202
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jwindhager |
Type: Bug | Status: new
Component: | Version: 2.1
contrib.admin | Keywords: proxy,
Severity: Normal | InlineModelAdmin, E202
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Assume the following Django models:

{{{#!python

class Reporter(models.Model):
...


class Journalist(Reporter):
...

class Meta:
proxy = True


class Article(models.Model):
reporter = models.ForeignKey(Reporter)
...

}}}

Register model admins as follows (exemplary):
{{{#!python

class ArticleInline(admin.TabularInline):
model = Article
fk_name = 'reporter'
...


@admin.register(Journalist)
class JournalistAdmin(admin.ModelAdmin):
inlines = [ArticleInline]
...

}}}

This will result in the following error:
{{{
<class 'ArticleInline'>: (admin.E202) fk_name 'reporter' is not a
ForeignKey to 'Journalist'.
}}}

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

Django

unread,
Mar 20, 2019, 8:10:59 PM3/20/19
to django-...@googlegroups.com
#30273: ModelAdmin for proxy model with InlineModelAdmin for superclass reference
results in admin.E202
-------------------------------------+-------------------------------------
Reporter: jwindhager | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: proxy, | Triage Stage: Accepted
InlineModelAdmin, E202 |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
Apr 13, 2019, 10:34:12 AM4/13/19
to django-...@googlegroups.com
#30273: ModelAdmin for proxy model with InlineModelAdmin for superclass reference
results in admin.E202
-------------------------------------+-------------------------------------
Reporter: jwindhager | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: proxy, | Triage Stage: Accepted
InlineModelAdmin, E202 |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Amir Hadi):

* Attachment "test30273.zip" added.

DemoProject which actually works

Django

unread,
Apr 13, 2019, 10:35:36 AM4/13/19
to django-...@googlegroups.com
#30273: ModelAdmin for proxy model with InlineModelAdmin for superclass reference
results in admin.E202
-------------------------------------+-------------------------------------
Reporter: jwindhager | Owner: nobody
Type: Bug | Status: closed

Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: proxy, | worksforme
InlineModelAdmin, E202 | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Amir Hadi):

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


Comment:

This works for me. I attached a demo project, please have a look. Maybe I
did misunderstood you somehow. I tested with Django 2.1.7 and master.

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

Reply all
Reply to author
Forward
0 new messages