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