[Answered ]-Django Generic View Model Filtering

1👍

Try,

class YourView(ListView):
    model = product

    def get_queryset(self):
        queryset = super(YourView, self).get_queryset()
        #your condition here.
        return queryset.filter(pk__in=[1,2,3])

1👍

Just split it into 2 lines:

model = Product

and

queryset = Product.objects.filter(pk__in=[1,2,3,4,5])

It will work.

0👍

implement an extra function in your “views.py” to handle the search

👤qiang

Leave a comment