range from first post to last post
This commit is contained in:
@@ -177,12 +177,10 @@ class PostSearchForm(forms.Form):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
first_post = Post.objects.get_queryset().last()
|
first_post = Post.objects.get_queryset().last()
|
||||||
|
last_post = Post.objects.get_queryset().first()
|
||||||
if first_post:
|
if first_post and last_post:
|
||||||
year_of_first_post = first_post.public_date.year
|
years = range(first_post.date.year, last_post.date.year + 1)
|
||||||
years = range(year_of_first_post, timezone.now().date().year + 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:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user