Answer the question
In order to leave comments, you need to log in
Why is the name field not displayed by id?
{% for i in cart_items %}
<h3><a href="/product/{{ i }}">{{ prod.i.name }}</a> </h3>
<a href="/cart/remove/{{ i }}" class="btn btn-danger" role="button">Удалить</a>
<hr>
{% endfor %}
views.py
items = request.session['items']
return render_to_response('show_cart.html', {'prod': Product.objects.all(), 'cart_items': items })
Answer the question
In order to leave comments, you need to log in
Must be something along the lines of
{% for i in cart_items %}
<h3><a href="/product/{{ i.id }}">{{ i.name }}</a> </h3>
<a href="/cart/remove/{{ i.id }}" class="btn btn-danger" role="button">Удалить</a>
<hr>
{% endfor %}
views.py
items = request.session['items']
return render_to_response('show_cart.html', {'cart_items': Product.objects.filter(id__in=items, ) })
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question