From a3042caa202c214043f29bb4fa43d135c504ddaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Mon, 20 Feb 2023 21:33:15 +0100 Subject: [PATCH] Use date and datetime inputs Properly implements 4d91a76513 --- games/forms.py | 13 +++++++++++++ timetracker/settings.py | 2 ++ 2 files changed, 15 insertions(+) diff --git a/games/forms.py b/games/forms.py index 42ebf8b..66c6c79 100644 --- a/games/forms.py +++ b/games/forms.py @@ -2,6 +2,11 @@ from django import forms from games.models import Game, Platform, Purchase, Session, Edition, Device +custom_date_widget = forms.DateInput(attrs={"type": "date"}) +custom_datetime_widget = forms.DateTimeInput( + attrs={"type": "datetime-local"}, format="%Y-%m-%d %H:%M" +) + class SessionForm(forms.ModelForm): purchase = forms.ModelChoiceField( @@ -9,6 +14,10 @@ class SessionForm(forms.ModelForm): ) class Meta: + widgets = { + "timestamp_start": custom_datetime_widget, + "timestamp_end": custom_datetime_widget, + } model = Session fields = [ "purchase", @@ -30,6 +39,10 @@ class PurchaseForm(forms.ModelForm): platform = forms.ModelChoiceField(queryset=Platform.objects.order_by("name")) class Meta: + widgets = { + "date_purchased": custom_date_widget, + "date_refunded": custom_date_widget, + } model = Purchase fields = [ "edition", diff --git a/timetracker/settings.py b/timetracker/settings.py index 55ee615..5fea37c 100644 --- a/timetracker/settings.py +++ b/timetracker/settings.py @@ -149,3 +149,5 @@ if _csrf_trusted_origins: CSRF_TRUSTED_ORIGINS = _csrf_trusted_origins.split(",") else: CSRF_TRUSTED_ORIGINS = [] + +USE_L10N = False