Try change this,
If self.kwargs[field] is not None:
With
if self.kwargs[field]: <--- this will return True it the field is not empty
This is the better way to filter, if you want filter the fields is empty
then just add not like this example
if not self.kwargs[field]:
On Sun, Jun 7, 2020, 1:06 AM
Hello to everyone,
i have a viewset (ModelViewset) for a model in my views.py, and i would
like the list endpoint to list me things matching some parameters (but the
are optional). So i have built this mixin:
class MultipleFieldLookupMixin(object):
"""
Apply this mixin to any view or views
2 matches
Mail list logo