0
我正在使用夾層&夾層的在線商店的實施。 我想要使用墨盒商店中的類別(product_category)包含「特色產品」部分。我創建了一個測試類別,使用條目填充它,並試圖從主頁查看它,但它不返回任何內容。我應該怎麼做呢?夾層項目主頁上的特色產品
的index.html
{% with category as "featured" %}
{% for product in products.object_list %}
(只使用category.html產品展示HTML現在)
views.py
def index(request):
products = Product.objects.all()
context = {'products': products}
return render(request, 'index.html', context)