3
Talk guys, good morning, I have a problem. I’m walking through a lista
but I want to concatenar
my list I’m calling on template
as {{ list }}
and {{ forloop.counter0 }}
so that in mine is only displayed 1
list item at a time and not all of it
py views.:
def user_donations(request):
donations = Donation.objects.all().filter(donor_id=request.user.id)
donationItem = DonationItem.objects.all().filter(donation__donor_id=request.user.id)
list = []
for item in donationItem:
list.append(item.material.name)
content = {'donations':donations, 'list': list}
return render(request, 'user-donations.html', content)
html.py:
{% extends 'base.html' %}
{% load static %}
{% block content%}
<section class="user-donations">
<div class="register-header-desktop">
<h2>Minhas doações</h2>
</div>
<div class="container register">
<div class="donations-list">
{% for donation in donations %}
<div class="modal">
<div class="confirm-school-name">
<span>{{ donation.created_at }}</span>
<span>De: {{ donation.donor }}</span>
<span>Para: {{ donation.school }}</span>
</div>
<div class="list-itens">
<span>{{ list.forloop.counter0 }}</span>
<span></span>
</div>
<div class="confirm-delivery">
<span></span>
</div>
<div class="arrow">
<img src="{% static 'images/arrow-down-icon.png' %}" alt="">
</div>
</div>
{% endfor %}
</div>
</div>
</section>
{% endblock %}
But the way I’m trying not to, someone can help me ?
You want to spin one
for
iterating on the items?– ThiagoO
exact @Thiagoluizs, for example on this
{{ list }}
I have 3 items, I want to concatenate with the{{ forloop.counter0 }}
so that every time myfor
Rotate when you arrive at the{{ list }}
is added a number so that it accesses an index of the vector oflist
ex: first round{{ list.0 }}
second round{{ list.1 }}
and so on. Draw ?– Raphael Melo De Lima