I'm looking for a way to use filter_horizontal on the base of a filtered queryset.
I've tried to use it with a custom manager:
In models.py:
class AvailEquipManager(models.Manager):
def get_query_set(self):
return super(AvailEquipManager, self).get_query_set().filter(id=3)
class Equipment(models.Model):
description = models.CharField(max_length=50)
manufacturer = models.ForeignKey(Manufacturer)
[...]
objects = models.Manager()
avail = AvailEquipManager()
def __unicode__(self):
return u"%s" % (self.description)
In admin.py:
class SystemAdmin(admin.ModelAdmin):
filter_horizontal = ('equipment',) # this works but obviously shows all entries
#filter_horizontal = ('avail',) # this does not work
So the questions is, how can I reduce the left side of the filter_horizontal to show only specific items?

所有评论(0)