Opened 6 years ago

Closed 6 years ago

#22212 closed Uncategorized (duplicate)

System check does incorrectly report an error for GenericTabularInline

Reported by: Matthias Pronk <django@…> Owned by: nobody
Component: Core (System checks) Version: 1.7-alpha-2
Severity: Release blocker Keywords: contenttype admin systemcheck generic
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When I create a inline for a generic relation:

class ObjectImage(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')

class BlockImages(models.Model):
    images = generic.GenericRelation(ObjectImage)

from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline

class ObjectImageInline(GenericTabularInline):
    model = ObjectImage

class BlockImagesAdmin(admin.MoedelAdmin):
    inlines = [ObjectImageInline], BlockImagesAdmin)

I get the following error message when running ./ migrate:

CommandError: System check identified some issues:

<class 'foo.admin.BlockImageInline'>: (admin.E202) 'foo.ObjectImage' has no ForeignKey to 'foo.BlockImages'.

Apparently, the new System Checks in Django 1.7 (1.6 does not show this problem) do not take into account Generic Relations.

Change History (1)

comment:1 Changed 6 years ago by Baptiste Mispelon

Resolution: duplicate
Status: newclosed


This looks like the same error as the one reported in #22034.


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