Skip to content

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

Open
@codeSamuraii

Description

@codeSamuraii

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions