filter_fields with DjangoFilterBackend

Viewed 230

I have a model called Product

class Product(models.Model):
    id
    name
    created_at
    updated_at
    price
    and so on....

i want to filter using all of the above attributes, which will be passed in query_params

at this moment i am using DjangoFilterBackends with filter_fields but to support all attributes i have to mention all the attributes in filter_fields like below in views

filter_fields = ['id', 'name', 'created_at', 'updated_at', 'price']

its working fine, but in actual model the fields are alot, which is causing code quality degradation.

is there any way to include all fields in filter_fields ?? i tried filter_fiels = ['__all__'], but its not working.

0 Answers
Related