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> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Accounts</th>
<th>Aktiv</th> <th>Aktiv</th>
<th>Aktionen</th> <th>Aktionen</th>
</tr> </tr>
@ -22,6 +23,7 @@
{% for x in mymembers %} {% for x in mymembers %}
<tr> <tr>
<td><a href="{% url 'details' x.id %}"><img src="{% static 'icons/arrow-right.svg' %}" class="icon">{{ x.nachname }} {{ x.vorname}}</a> </td> <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>{% 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> <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> </tr>

View File

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