From 613fe2447d7a56d2fc6f15c1c1e6fb9839a2dff6 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 5 May 2020 16:07:53 +0200 Subject: [PATCH] Use timezone --- apps/tournament/forms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/tournament/forms.py b/apps/tournament/forms.py index 9518d97..fc8ed21 100644 --- a/apps/tournament/forms.py +++ b/apps/tournament/forms.py @@ -1,9 +1,9 @@ import os import re -from datetime import datetime from django import forms from django.db.models import Q +from django.utils import timezone from django.utils.translation import gettext_lazy as _ from member.models import TFJMUser, Solution, Synthesis @@ -62,7 +62,7 @@ class OrganizerForm(forms.ModelForm): class TeamForm(forms.ModelForm): tournament = forms.ModelChoiceField( - Tournament.objects.filter(date_inscription__gte=datetime.today(), final=False), + Tournament.objects.filter(date_inscription__gte=timezone.now().date(), final=False), ) class Meta: @@ -84,7 +84,7 @@ class TeamForm(forms.ModelForm): if Team.objects.filter(name=cleaned_data["name"], year=os.getenv("TFJM_YEAR")).exists(): self.add_error("name", _("This name is already used.")) - if cleaned_data["tournament"].date_inscription < datetime.today(): + if cleaned_data["tournament"].date_inscription < timezone.now().date(): self.add_error("tournament", _("This tournament is already closed.")) return cleaned_data