2👍
✅
def get_filter_result(request):
queryset = Customer.objects.filter(active=True)
customer_type = request.GET.get('customer_type','')
if customer_type:
queryset = queryset.filter(customer_type=customer_type)
tags = request.GET.getlist('tag')
if tags:
queryset = queryset.filter(tag__id__in=tags)
<...>
return queryset.order_by('name')
Source:stackexchange.com