philipn/django-rest-framework-filters

TypeError: 'Meta.fields' must not contain non-model field names

codeSamuraii opened this issue · 2 comments

Hello,

I get the following error :

[...]
    class CompanyFilter(filters.FilterSet):
  File "/Users/remi/Programmation/IgnitionProgram/igniback/venv3/lib/python3.8/site-packages/rest_framework_filters/filterset.py", line 38, in __new__
    cls.expand_auto_filters(new_class)
  File "/Users/remi/Programmation/IgnitionProgram/igniback/venv3/lib/python3.8/site-packages/rest_framework_filters/filterset.py", line 66, in expand_auto_filters
    for gen_name, gen_f in new_class.get_filters().items():
  File "/Users/remi/Programmation/IgnitionProgram/igniback/venv3/lib/python3.8/site-packages/django_filters/filterset.py", line 358, in get_filters
    raise TypeError(
TypeError: 'Meta.fields' must not contain non-model field names: contact

Although contact is not in the fields:

class CompanyFilter(filters.FilterSet):

    contact = filters.RelatedFilter(ContactFilter, name='contact', queryset=Contact.objects.all())
    owner = filters.RelatedFilter(CustomUserFilter, name='owner', queryset=CustomUser.objects.all())

    class Meta:
        model = Company
        fields = ['status']

Does it comes from djangorestframework-filters or django-filter ?

Django==3.0.5
django-filter==2.3.0
djangorestframework==3.11.0
djangorestframework-filters==1.0.0.dev0

Hi @codeSamuraii. Sorry for the long response time. Could you open a PR with a failing test case? The test suite is currently passing against:

Django                      3.1
django-filter               2.3.0
djangorestframework         3.11.1

Hi, Any other solution for this please ?