1👍
✅
You can’t use a function as a list filter.
list_filter
should be a list or tuple of elements, where each element should be of one of the following types:
a field name, where the specified field should be either a
BooleanField
,CharField
,DateField
,DateTimeField
,IntegerField
,ForeignKey
orManyToManyField
a class inheriting from
django.contrib.admin.SimpleListFilter
, which you need to provide thetitle
andparameter_name
attributes to and override thelookups
andqueryset
methodsa tuple, where the first element is a field name and the second element is a class inheriting from
django.contrib.admin.FieldListFilter
So for your case, you’ll want to subclass either the SimpleListFilter or FieldListFilter like the examples in the docs.
👤2ps
Source:stackexchange.com