carltongibson / django-filter

A generic system for filtering Django QuerySets based on user selections
https://django-filter.readthedocs.io/en/main/
Other
4.46k stars 769 forks source link

Filterset issue - unrecognized field type FileField #1502

Closed andychoi closed 2 years ago

andychoi commented 2 years ago

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'],
        }
carltongibson commented 2 years ago

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