From f5367828ca55e8cf8f95f58c4217bd6a0f189850 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 5 May 2020 13:54:26 +0200 Subject: [PATCH] datetime are time-zoned --- apps/member/views.py | 2 +- apps/tournament/models.py | 10 +++++----- apps/tournament/views.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/member/views.py b/apps/member/views.py index be6de1c..4cbc4fb 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -1,5 +1,4 @@ import random -from datetime import timezone from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.models import AnonymousUser @@ -8,6 +7,7 @@ from django.db.models import Q from django.http import FileResponse from django.shortcuts import redirect from django.urls import reverse_lazy +from django.utils import timezone from django.utils.translation import gettext_lazy as _ from django.views import View from django.views.generic import CreateView, UpdateView, DetailView, FormView diff --git a/apps/tournament/models.py b/apps/tournament/models.py index 6880cd5..076df42 100644 --- a/apps/tournament/models.py +++ b/apps/tournament/models.py @@ -1,8 +1,8 @@ import os -from datetime import date, datetime from django.db import models from django.urls import reverse_lazy +from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -36,12 +36,12 @@ class Tournament(models.Model): ) date_start = models.DateField( - default=datetime.today, + default=timezone.now().date(), verbose_name=_("date start"), ) date_end = models.DateField( - default=datetime.today, + default=timezone.now().date(), verbose_name=_("date end"), ) @@ -75,7 +75,7 @@ class Tournament(models.Model): ) year = models.PositiveIntegerField( - default=os.getenv("TFJM_YEAR", date.today().year), + default=os.getenv("TFJM_YEAR", timezone.now().year), verbose_name=_("year"), ) @@ -153,7 +153,7 @@ class Team(models.Model): ) year = models.PositiveIntegerField( - default=os.getenv("TFJM_YEAR", date.today().year), + default=os.getenv("TFJM_YEAR", timezone.now().year), verbose_name=_("year"), ) diff --git a/apps/tournament/views.py b/apps/tournament/views.py index cc6d6e2..49c6478 100644 --- a/apps/tournament/views.py +++ b/apps/tournament/views.py @@ -1,6 +1,5 @@ import random import zipfile -from datetime import timezone from io import BytesIO from django.contrib.auth.mixins import LoginRequiredMixin @@ -11,6 +10,7 @@ from django.http import HttpResponse from django.shortcuts import redirect from django.template.loader import render_to_string from django.urls import reverse_lazy +from django.utils import timezone from django.utils.decorators import method_decorator from django.utils.translation import gettext_lazy as _ from django.views import View