Opened 17 years ago
Closed 17 years ago
#7138 closed (duplicate)
list_filter ignores foreign keys to inherited models
| Reported by: | tsouanas | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| 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: | no | UI/UX: | no |
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.
Change History (2)
comment:1 by , 17 years ago
| Component: | Uncategorized → Admin interface |
|---|
comment:2 by , 17 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Model inheritance is not expected to work in the admin.
See #6755.