Opened 5 years ago

Closed 5 years ago

#30273 closed Bug (worksforme)

ModelAdmin for proxy model with InlineModelAdmin for superclass reference results in admin.E202

Reported by: jwindhager Owned by: nobody
Component: contrib.admin Version: 2.1
Severity: Normal Keywords: proxy, InlineModelAdmin, E202
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Assume the following Django models:

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

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

Attachments (1)

test30273.zip (12.4 KB ) - added by Amir Hadi 5 years ago.
DemoProject which actually works

Download all attachments as: .zip

Change History (3)

comment:1 by Tim Graham, 5 years ago

Triage Stage: UnreviewedAccepted

by Amir Hadi, 5 years ago

Attachment: test30273.zip added

DemoProject which actually works

comment:2 by Amir Hadi, 5 years ago

Resolution: worksforme
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top