[Fixed]-Cannot resolve keyword 'XXX' into field

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 or ManyToManyField

  • a class inheriting from django.contrib.admin.SimpleListFilter, which you need to provide the title and parameter_name attributes to and override the lookups and queryset methods

  • a 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

Leave a comment