Make pagination dates aware to avoid warnings
This commit is contained in:
parent
f7f3f9955e
commit
7392532f71
|
@ -1,6 +1,7 @@
|
|||
import datetime
|
||||
|
||||
from django.utils.text import slugify
|
||||
from django.utils.timezone import make_aware
|
||||
|
||||
from .models import Thought
|
||||
|
||||
|
@ -47,18 +48,18 @@ class SeasonPage(Page):
|
|||
def __init__(self, current_season, current_year):
|
||||
super().__init__(formatted_name_for_season_year(current_season, current_year))
|
||||
|
||||
self.first_day_of_season = datetime.date(
|
||||
self.first_day_of_season = make_aware(datetime.datetime(
|
||||
current_year,
|
||||
12 if current_season == 0 else current_season * 3,
|
||||
1
|
||||
)
|
||||
))
|
||||
# If the current season is winter, then the next season starts on the next year
|
||||
# This is actually the first day of the next season but that's hard to type out and it's 2am
|
||||
self.last_day_of_season = datetime.date(
|
||||
self.last_day_of_season = make_aware(datetime.datetime(
|
||||
current_year + (1 if current_season == 0 else 0),
|
||||
12 if current_season == 3 else (current_season + 1) * 3,
|
||||
1
|
||||
)
|
||||
))
|
||||
|
||||
def get_all_entries(self):
|
||||
return Thought.objects.order_by("-posted").filter(
|
||||
|
|
Loading…
Reference in New Issue