diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index e35742c7..8e71fed3 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -535,7 +535,9 @@ class PosledniCisloVysledkovkaView(generic.DetailView): def get_context_data(self, **kwargs): context = super(PosledniCisloVysledkovkaView, self).get_context_data() rocnik = context['rocnik'] - cislo = rocnik.cisla.order_by("poradi").last() + cislo = rocnik.cisla.order_by("poradi").filter(deadline_v_cisle__isnull=False).last() + if cislo is None: + raise Http404(f"Ročník {rocnik.rocnik} nemá číslo s deadlinem.") cislopred = cislo.predchozi() context['vysledkovka'] = VysledkovkaDoTeXu( cislo,