I have custom filter to my viewset:
class OrderFilter(django_filters.rest_framework.FilterSet):
username = django_filters.CharFilter(name='user__username', lookup_expr='icontains')
client_name = django_filters.CharFilter(name='user__first_name', lookup_expr='icontains')
class Meta:
model = Order
exclude = ['pk']
And it works when I send query like this:
http://localhost:8000/orders/?username=testuser
or
http://localhost:8000/orders/?client_name=john
but I want to create only one query to search data containing search string in username
, first_name
and last_name
. How to do it?