optimize setting a year in posts choices.
This commit is contained in:
@@ -63,8 +63,17 @@ def index(request):
|
|||||||
fet_meeting_only,
|
fet_meeting_only,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
last_post_year = Post.objects.get_queryset().first().date.year
|
||||||
|
now_year = timezone.now().year
|
||||||
|
|
||||||
|
# if the last post is a year old or more, then set year to it
|
||||||
|
if last_post_year < now_year:
|
||||||
|
year = last_post_year
|
||||||
|
else:
|
||||||
|
year = now_year
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'year': timezone.now().year,
|
'year': year,
|
||||||
}
|
}
|
||||||
|
|
||||||
form = PostSearchForm(data)
|
form = PostSearchForm(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user