** URl:**
path('products_filter/', views.products_filter, name='products_filter'),**查看:**
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})**模板:**
<a href="/product/products_filter?product={{'carpet'|urlencode}}&selling={{'best_seller'|urlencode}}">发布于 2020-07-10 21:27:03
将要从url中检索的参数添加到您的url中,并确保模板中的url添加了这些参数。例如:
urls.py:
path('products_filter/<str:product>/<str:selling>/', views.products_filter, name='products_filter'),模板:
<a href="{% url 'products_filter' product=carpet|urlencode selling=best_seller|urlencode %}">https://stackoverflow.com/questions/62834540
复制相似问题