1๐
โ
I have created a pages app. look where is the template.
views.py
from django.shortcuts import render
from .models import Appeal
from django.db.models import Count
def index(request):
qs = Appeal.objects.values(
"organization__organization_name", "appeal_form__form_name"
).annotate(total=Count("appeal_form__form_name"))
context = {
"appeal": qs,
}
return render(request, "pages/index.html", context)
index.html
<table>
<tr>
<th>Organization</th>
<th>Appeal Form</th>
<th>Amount of appeals in this form</th>
</tr>
{% for item in appeal %}
<tr>
<td>{{ item.organization__organization_name }}</td>
<td>{{ item.appeal_form__form_name }}</td>
<td>{{ item.total }}</td>
</tr>
{% endfor %}
</table>
pages
โโโ __init__.py
โโโ admin.py
โโโ apps.py
โโโ migrations
โโโ models.py
โโโ templates
โ โโโ pages
โ โโโ index.html
โโโ tests.py
โโโ urls.py
โโโ views.py
๐คA D
Source:stackexchange.com