0

** URl : **

path('products_filter/', views.products_filter, name='products_filter'),

** VIEW :**

def products_filter(request):
    product = request.GET.get('product')
    selling = request.GET.get('selling')
    
    products = Product.objects.filter(selling='best_seller')

    return render(request, 'product/products.html', {'products':products})

** TEMPLATE : **

<a href="/product/products_filter?product={{'carpet'|urlencode}}&selling={{'best_seller'|urlencode}}">
1
  • can we see your model? Commented Jul 10, 2020 at 12:57

1 Answer 1

1

add the parameters you want to retrieve from the url to your url and make sure the url in the template adds them. For example:

urls.py:

path('products_filter/<str:product>/<str:selling>/', views.products_filter, name='products_filter'),

template:

<a href="{% url 'products_filter' product=carpet|urlencode selling=best_seller|urlencode %}">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.