Reputation: 11
I have a shopping site and I want implement sorting products in my site I know how order_by works but I don't know how to pass arguments through url to check it I use class base view (ListView)
my view:
class ProductList(ListView):
template_name = 'products/store.html'
paginate_by = 8
def get_queryset(self):
return Product.objects.get_active_products()
I use dropdown (with tag a) for finding witch order user want to sort
for example in amazon when you sort items "&s=price-asc" has added to url that means we sort ascending
Upvotes: 1
Views: 211
Reputation: 359
You can use dict with request parameters from self.request.GET
in get_queryset(self)
method.
Upvotes: 1