Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
codeSamuraii opened this issue Jun 23, 2020 · 2 comments
Open
Labels

Comments

@codeSamuraii
Copy link

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
@rpkilby
Copy link
Collaborator

rpkilby commented Aug 8, 2020

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

@rpkilby rpkilby added the bug label Aug 8, 2020
@rikckie
Copy link

rikckie commented May 16, 2023

Hi, Any other solution for this please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants