Code

Opened 6 years ago

Closed 6 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:

Description

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(self.name)

    class Admin:
        pass


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

    class Admin:
        pass


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

    class Admin:
        pass


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.

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by tsouanas

  • Component changed from Uncategorized to Admin interface
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by ramiro

  • Resolution set to duplicate
  • Status changed from new to closed

Model inheritance is not expected to work in the admin.

See #6755.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.