Adding account count to main person list

This commit is contained in:
Michael Bergbauer 2025-06-18 08:24:22 +02:00
parent 042ec3760f
commit 3288c1b107
2 changed files with 4 additions and 1 deletions

View File

@ -14,6 +14,7 @@
<thead>
<tr>
<th>Name</th>
<th>Accounts</th>
<th>Aktiv</th>
<th>Aktionen</th>
</tr>
@ -22,6 +23,7 @@
{% for x in mymembers %}
<tr>
<td><a href="{% url 'details' x.id %}"><img src="{% static 'icons/arrow-right.svg' %}" class="icon">{{ x.nachname }} {{ x.vorname}}</a> </td>
<td>{{x.accounts}}</td>
<td>{% if x.aktiv %}{% inline_svg 'icons/uxwing/check.svg' 'icon' %}{% endif %}</td>
<td><a href="{% url 'edit' x.id %}" title="Bearbeiten"><img src="{% static 'icons/heroicons/pencil.svg'%}" class="icon"></a> <a href="{% url 'delete' x.id %}" title="Löschen"><img src="{% static 'icons/heroicons/trash.svg'%}" class="icon"></a></td>
</tr>

View File

@ -1,11 +1,12 @@
from django.http import HttpResponse
from django.shortcuts import render, redirect, get_object_or_404
from django.template import loader
from django.db.models import Count
from .models import Person
from .forms import PersonForm
def members(request):
mymembers=Person.objects.all().values()
mymembers=Person.objects.annotate(accounts=Count('benutzerkonten'))
template=loader.get_template("memberlist.html")
context = {
'mymembers': mymembers