Hi, I want to use django's admin filter on the list page. The models I have are something like this:
class Location(model):
name = CharField()
class Inquiry(Model):
name = CharFiled()
location = ManyToManyField(Location)
Now I want to filter Inquiries, to display only those that contain relation to specific Location object. If I use
class InqAdmin(ModelAdmin):
list_filter = ['location', ]
admin.site.register(Inquiry, InqAdmin)
the admin page displays me the list of all Locations
and allows to filter.
What I would like to get, is to get list of only those locations that have some Inquiries
in relation to them (so I don't ever get the empty list result after filtering).
How can this be done?