use make_aware
This commit is contained in:
parent
a90914fa8e
commit
c192f91a03
1 changed files with 2 additions and 1 deletions
|
@ -59,11 +59,12 @@ class Item(models.Model):
|
|||
@classmethod
|
||||
def public(cls, now=None):
|
||||
if now is None:
|
||||
now = timezone.now()
|
||||
now = timezone.make_aware(datetime.now(), timezone.get_default_timezone())
|
||||
qs = cls.objects.exclude(published=None).filter(published__lte=now).order_by('-published')
|
||||
cal = now.date().isocalendar()
|
||||
monday = now.date() - timedelta(days=now.date().isocalendar().weekday - 1)
|
||||
monday = timezone.datetime(monday.year, monday.month, monday.day, tzinfo=now.tzinfo)
|
||||
print(monday)
|
||||
first_post = qs.filter(published__gt=monday).first()
|
||||
if first_post and first_post.published < now:
|
||||
week = qs.filter(published__gt=monday)
|
||||
|
|
Loading…
Reference in a new issue