Good day guyz
sorry i'm working on a django e-commerce project which i am new to, and i'm
stuck, i wan have a page that will display the list of all for the list of
all products under a particular category, which i have checked out on
stackoverflow, i tried every suggestion and yet since not working below is
my code hoping anyone can lead mr in d right direction

##View

def index(request):
products = Product.objects.all()
category = get_list_or_404(Category)
cat = Category.objects.filter(pk = id)
return render(request, 'shop/index.html', locals())

##product_list Page
<h2>Categories</h2>
{% if cat %}
<ul>
{% for c in cat %}
<li>
<a href="{% url 'product-list' %}"> {{c.name}}</a>
</li>
{% for product in cat.get_product %}
<p> {(product.name}}</p>
{% endfor %}
{% endfor %}
</ul>
{% else %}
<p> There's no item category yet
{% endif %}
</div>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHLKn70PDKYwv30LhTsRaQEJ5V9mwE0xri-EdmwPp8ZoAC5nng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to