From bd8d30eac18f26ca9d8d56358c8415f49f66be93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Wed, 15 Nov 2023 17:47:51 +0100 Subject: [PATCH] Improve time-related stuff Add created_at to all models Add modified_at to Session Get rid of custom now() function Make sure aware datetime is used everywhere --- games/views.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/games/views.py b/games/views.py index fa568fb..6b348fd 100644 --- a/games/views.py +++ b/games/views.py @@ -1,7 +1,6 @@ from common.time import format_duration from common.utils import safe_division from datetime import datetime, timedelta -from django.conf import settings from django.db.models import Sum, F, Count, Prefetch from django.db.models.functions import TruncDate from django.http import HttpRequest, HttpResponse, HttpResponseRedirect @@ -9,7 +8,6 @@ from django.shortcuts import redirect, render from django.urls import reverse from django.utils import timezone from typing import Callable, Any -from zoneinfo import ZoneInfo from .forms import ( GameForm, @@ -279,7 +277,7 @@ def list_sessions( dataset = Session.objects.filter(purchase__ownership_type=ownership_type) context["ownership_type"] = dict(Purchase.OWNERSHIP_TYPES)[ownership_type] elif filter == "recent": - current_year = datetime.now().year + current_year = timezone.now().year first_day_of_year = datetime(current_year, 1, 1) dataset = Session.objects.filter( timestamp_start__gte=first_day_of_year