reverse year range

This commit is contained in:
2022-01-24 13:07:56 +00:00
parent 97b7af80c4
commit 626da78994

View File

@@ -177,7 +177,7 @@ class PostSearchForm(forms.Form):
first_post = Post.objects.get_queryset().last() first_post = Post.objects.get_queryset().last()
last_post = Post.objects.get_queryset().first() last_post = Post.objects.get_queryset().first()
if first_post and last_post: if first_post and last_post:
years = range(first_post.date.year, last_post.date.year + 1) years = range(last_post.date.year, first_post.date.year - 1, -1)
year_choices = [("", _("Alle"))] + [(i, i) for i in years] year_choices = [("", _("Alle"))] + [(i, i) for i in years]
self.fields["year"].choices = year_choices self.fields["year"].choices = year_choices
except: except: