#22034: Checks for ModelAdmin ForeignKeys fail with GenericInlineModelAdmin -------------------------------+-------------------- Reporter: jwa | Owner: nobody Type: Bug | Status: new Component: contrib.admin | Version: master Severity: Normal | Keywords: checks Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+-------------------- Checks `admin.E202` fail when trying to detect a `ForeignKey` from a `GenericInlineModelAdmin`:
The following setup yields this error: {{{ <class 'app.admin.BarInline'>: (admin.E202) 'app.Bar' has no ForeignKey to 'app.Foo'. }}} `models.py` {{{ class Foo(models.Model): """Foo may have some Bars.""" text = models.TextField() class Bar(models.Model): text = models.TextField() content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') }}} `admin.py` {{{ class BarInline(GenericStackedInline): model = Bar @admin.register(Foo) class FooAdmin(admin.ModelAdmin): inlines = [BarInline] }}} I think this will require an exception in `_check_fk_name` for generic InlineAdmin classes here: https://github.com/django/django/blob/06bd181f97e5e5561ae7e80efae4c38ee670773f/django/contrib/admin/checks.py#L866 -- Ticket URL: <https://code.djangoproject.com/ticket/22034> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/046.9b28cf2d200f3af74627e83ed8d5840d%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.