1#There is Q objects that allow to complex lookups. Example:
2from django.db.models import Q
3
4Item.objects.filter(Q(creator=owner) | Q(moderated=False))
5
1import django_filters
2
3class ProductFilter(django_filters.FilterSet):
4 # lookup_expr='iexact'
5 # lookup_expr='icontains'
6 name = django_filters.CharFilter(lookup_expr='iexact')
7
8 class Meta:
9 model = Product
10 fields = ['price', 'release_date']
11
1from django_filters import rest_framework as filters
2
3class ProductFilter(filters.FilterSet):
4 class Meta:
5 model = Product
6 fields = ('field')
1def product_list(request):
2 filter = ProductFilter(request.GET, queryset=Product.objects.all())
3 return render(request, 'my_app/template.html', {'filter': filter})