I want to create a list view that searches a large dataset. But it seems 
that if I use a filterset with empty defaults, then my view displays my 
entire dataset.

If tried creating a get_queryset method in my view that detects whether my 
filter fields are empty, but this doesn't seem to have any effect:

from django_filters.views import FilterView
from .filters import ProductFilter

class ProductView(FilterView):
    filterset_class = ProductFilter
    template_name = 'product_filter.html'

    def get_queryset(self):
        qs = super(ProductView, self).get_queryset()
        if '' not in self.request.GET.items():
            return qs.none()
        else:
            return qs

I looked at and experimented with STRICTNESS, but it didn't seem to have 
any effect either. How can I create a view that refrains from displaying 
data until I give it valid filter fields?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c10caaab-879b-44fe-ba35-4886b08d2ca9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to