Opened 10 years ago

Closed 10 years ago

#7138 closed (duplicate)

list_filter ignores foreign keys to inherited models

Reported by: tsouanas Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: list_filter admin inheritance
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Here is the troublesome code:

class Restaurant(models.Model):
    name = models.CharField(max_length=32)
    address = models.CharField(max_length=200, null=True, blank=True)

    def __unicode__(self):
        return unicode(

    class Admin:

class Italian(Restaurant):
    traditional = models.BooleanField(null=True, blank=True)

    class Admin:

class Chinese(Restaurant):
    only_chopsticks = models.BooleanField(null=True, blank=True)

    class Admin:

class Mobster(models.Model):
    name = models.CharField(max_length=48)
    fav_italian = models.ForeignKey(Italian, related_name="mobster_italian", null=True, blank=True)
    fav_restaurant = models.ForeignKey(Restaurant, related_name="mobster_restaurant", null=True, blank=True)

    class Admin:
        list_display = ('name', 'fav_italian', 'fav_restaurant')
        list_filter = ('name', 'fav_italian', 'fav_restaurant')

On the filters, only 'name' and 'fav_restaurant' are available. To actually filter with respect to fav_italian, I have to alter the URL.

Change History (2)

comment:1 Changed 10 years ago by tsouanas

Component: UncategorizedAdmin interface

comment:2 Changed 10 years ago by Ramiro Morales

Resolution: duplicate
Status: newclosed

Model inheritance is not expected to work in the admin.

See #6755.

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