Talk to people, good morning, I have a problem. I'm running a lista
but I want concatenar
my list that I'm calling in template
as {{ list }}
and {{ forloop.counter0 }}
so that in my is only displayed 1
list item at time and not her entire
views.py:
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 is not working, can anyone help me?