From a72435dd724b0a2a394a8a77973b4ce2d60f4d0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= <jonas.havelka@volny.cz>
Date: Tue, 30 Jan 2024 00:02:27 +0100
Subject: [PATCH] =?UTF-8?q?Zrychlen=C3=AD=20na=C4=8D=C3=ADt=C3=A1n=C3=AD?=
 =?UTF-8?q?=20archivu=20soust=C5=99ed=C4=9Bn=C3=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../templates/soustredeni/seznam_soustredeni.html     |  8 ++++----
 soustredeni/views.py                                  | 11 +++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/soustredeni/templates/soustredeni/seznam_soustredeni.html b/soustredeni/templates/soustredeni/seznam_soustredeni.html
index fcb7c287..e5f68bfc 100644
--- a/soustredeni/templates/soustredeni/seznam_soustredeni.html
+++ b/soustredeni/templates/soustredeni/seznam_soustredeni.html
@@ -58,16 +58,16 @@
         {# Účastníci #}
         <h2>Soustředění se zúčastnili tito účastníci:</h2>
         <p>
-        {% for i in soustredeni.soustredeni_ucastnici_set.all %}
-          {{i.resitel}}{% if forloop.last %}.{% else %},{% endif %}
+        {% for i in soustredeni.ucastnici.all %}
+          {{i}}{% if forloop.last %}.{% else %},{% endif %}
         {% empty %}
           Nic!
         {% endfor %}
         </p>
         <h2>Soustředění se účastnili tito organizátoři:</h2>
         <p>
-        {% for i in soustredeni.soustredeni_organizatori_set.all %}
-          {{i.organizator}}{% if forloop.last %}.{% else %},{% endif %}
+        {% for i in soustredeni.organizatori.all %}
+          {{i}}{% if forloop.last %}.{% else %},{% endif %}
         {% empty %}
           Nic!
         {% endfor %}
diff --git a/soustredeni/views.py b/soustredeni/views.py
index e5ae2992..da59e779 100644
--- a/soustredeni/views.py
+++ b/soustredeni/views.py
@@ -17,6 +17,17 @@ class SoustredeniListView(generic.ListView):
 	model = Soustredeni
 	template_name = 'soustredeni/seznam_soustredeni.html'
 
+	def get_queryset(self):
+		return (
+			Soustredeni.objects
+			.prefetch_related(
+				"ucastnici", "ucastnici__osoba",
+				"organizatori", "organizatori__osoba",
+				"galerie_set"
+			)
+			.select_related("rocnik")
+		)
+
 
 def soustredeniObalkyView(request, soustredeni):
 	soustredeni = get_object_or_404(Soustredeni, id=soustredeni)