diff --git a/fet2020/posts/views.py b/fet2020/posts/views.py index 11ce0b70..a1bb1b0b 100644 --- a/fet2020/posts/views.py +++ b/fet2020/posts/views.py @@ -63,14 +63,18 @@ def index(request): fet_meeting_only, ) else: - last_post_year = Post.objects.get_queryset().first().date.year - now_year = timezone.now().year + last_year = Post.objects.get_queryset().first() + if last_year: + last_post_year = last_year.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 + # 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 else: - year = now_year + year = None data = { 'year': year,