[Fixed]-Multiple request filtr from url Djjango

1👍

Don’t format the URL like that. There is a perfectly suitable way of passing queries in URLs, and that is to use a querystring:

http://example.com/store/productlist/?category=1&category=2&category=3

(Also, why are you pretending your Django site is running on .NET? Don’t do that.)

Now your URL pattern just looks like this:

url(r'^productlist/$', 'shop.views.shoplist'),

and your view is:

def shoplist(request):
    categories = request.GET.getlist('category')
    if categories:
       products = ShopProduct.objects.filter(shop_product_category_id__in=categories)

Leave a comment