#34927: ModelAdmin for model with InlineModelAdmin for proxy class reference
results in admin.E202
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
ColonelPhantom |
Type: Bug | Status: new
Component: | Version: 4.2
Uncategorized | 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 |
-------------------------------------+-------------------------------------
This is similar to #30273 and #32975. A class references a proxy model,
and we define an inline for the proxied model. This fails with admin.E202
because Django does not recognize that the FK to the proxy model is the
same as an FK to the proxied model.
Assume models as follows:
{{{
class Reporter(models.Model):
name = models.CharField(max_length=50)
class Journalist(Reporter):
class Meta:
proxy = True
class Article(models.Model):
reporter = models.ForeignKey(Journalist, on_delete=models.CASCADE)
}}}
and an admin as follows:
{{{
class ArticleInline(admin.TabularInline):
model = Article
fk_name = 'reporter'
@admin.register(Reporter)
class ReporterAdmin(admin.ModelAdmin):
inlines = [ArticleInline]
}}}
This will result in {{{<class 'testapp.admin.ArticleInline'>: (admin.E202)
fk_name 'reporter' is not a ForeignKey to 'testapp.Reporter'.}}}
The problem seems to be that the parent list does not include the model
itself, and as such Django does not recognize the equality here.
--
Ticket URL: <https://code.djangoproject.com/ticket/34927>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018b684bc972-43882716-0199-4f86-84fb-ad67b273c011-000000%40eu-central-1.amazonses.com.