From 57733f174ceeed25772fc6bf69c78792a796091b Mon Sep 17 00:00:00 2001 From: Patrick Mayr Date: Tue, 18 Jan 2022 10:25:45 +0000 Subject: [PATCH] range from first post to last post --- fet2020/posts/forms.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fet2020/posts/forms.py b/fet2020/posts/forms.py index 9fb19ca2..4af8c780 100644 --- a/fet2020/posts/forms.py +++ b/fet2020/posts/forms.py @@ -177,12 +177,10 @@ class PostSearchForm(forms.Form): try: first_post = Post.objects.get_queryset().last() - - if first_post: - year_of_first_post = first_post.public_date.year - years = range(year_of_first_post, timezone.now().date().year + 1) + last_post = Post.objects.get_queryset().first() + if first_post and last_post: + years = range(first_post.date.year, last_post.date.year + 1) year_choices = [("", _("Alle"))] + [(i, i) for i in years] self.fields["year"].choices = year_choices - except: pass