How to get the filter class or viewset class through model?

287 views Asked by At

I want to find the corresponding filter class or viewset class only through Model.

The corresponding Model can be found by filter class or viewset class, but it cannot be reversed. I have a naming of these three, there is a rule, I guess it can be found through the string name of the filter class or viewset class, but it can not be achieved

class Manager(models.Model)
class ManagerFilter(filters.FilterSet):
    class Meta:
        model = Manager
        fields = {'name': ['exact', 'in', 'startswith']}
class ManagerViewSet(viewsets.ModelViewSet):
    filter_class = ManagerFilter

I can only get the Model class, I want to get the corresponding filter class or viewset class according to this Model.

0

There are 0 answers