Skip to content

Instantly share code, notes, and snippets.

View wjurkowlaniec's full-sized avatar
🎹

Wojtek Jurkowlaniec wjurkowlaniec

🎹
View GitHub Profile
from django.contrib.admin import FieldListFilter
from django.utils.translation import ugettext as _
class ActiveValueFilter(FieldListFilter):
"""list_filter which displays only the values for a field which are in use
This is handy when a large range has been filtered in some way which means
most of the potential values aren't currently in use. This requires a
queryset field or annotation named "item_count" to be present so it can