N
N
nazandr2016-03-21 19:46:55
Django
nazandr, 2016-03-21 19:46:55

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 })

At the request of prod.i.name, an empty field is displayed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Melnikov, 2016-03-21
@nazandr

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 question

Ask a Question

731 491 924 answers to any question