philipn/django-rest-framework-filters

How to get the filter class through model?

Closed this issue · 3 comments

I can't find an effective way. Has anyone implemented it?

Hi @Scheinin. Can you provide more information about what you expect to see? e.g., what do you expect to provide as input, and what do you expect in return?

@rpkilby

class ManagerFilter(filters.FilterSet):
    class Meta:
        model = Manager
        fields = {'name': ['exact', 'in', 'startswith']}

For example, I have this filter class. How can I get the ManagerFilter only through the Manager.

No. This is the minimal amount of code necessary to configure a FilterSet. It's basically the same API that's used by DRF serializers and Django model forms.