carltongibson / django-filter

A generic system for filtering Django QuerySets based on user selections

Home Page:https://django-filter.readthedocs.io/en/main/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filterset issue - unrecognized field type FileField

andychoi opened this issue · comments

Here is error.

AssertionError: ProjectFilterSet resolved field 'attachment' with 'exact' lookup to an unrecognized field type FileField. Try adding an override to 'Meta.filter_overrides'. See: https://django-filter.readthedocs.io/en/main/ref/filterset.html#customise-filter-generation-with-filter-overrides

My class has FileField, but I didn't include it in filter class as below. I tried to exclude, but still not working

class ProjectFilter(django_filters.FilterSet):

    class Meta:
        model = Project
        exclude = ['attachment']
        fields = {
            'title'         : ['icontains'],
            'description'   : ['icontains'],
        }

You can't provide fields and exclude at the same time. The fields setting should be sufficient? 🤔