Django

Code

Ticket #7138 (closed: duplicate)

Opened 4 months ago

Last modified 4 months ago

list_filter ignores foreign keys to inherited models

Reported by: tsouanas Assigned to: nobody
Milestone: Component: Admin interface
Version: SVN Keywords: list_filter admin inheritance
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Change History

04/30/08 04:55:52 changed by tsouanas

  • needs_better_patch changed.
  • component changed from Uncategorized to Admin interface.
  • needs_tests changed.
  • needs_docs changed.

04/30/08 05:42:16 changed by ramiro

  • status changed from new to closed.
  • resolution set to duplicate.

Model inheritance is not expected to work in the admin.

See #6755.


Add/Change #7138 (list_filter ignores foreign keys to inherited models)




Change Properties
Action