From 97f62a20f1716a9915358959b2e25912e8b17a90 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Wed, 17 Jan 2018 16:50:08 +0100 Subject: Utilisation des champs de formulaires date et time à la place de text --- forms.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/forms.py b/forms.py index d886dbf..0d823eb 100644 --- a/forms.py +++ b/forms.py @@ -14,17 +14,21 @@ # along with celcatsanitizer. If not, see . from datetime import timedelta + from django import forms +from django.forms.widgets import DateInput, TimeInput from .utils import tz_now class QSJPSForm(forms.Form): - day = forms.DateField(label="Jour") + day = forms.DateField(label="Jour", widget=DateInput(attrs={"type": "date"})) # Ces champs n’acceptent pas les secondes - begin = forms.TimeField(label="Heure de début", input_formats=("%H:%M",)) - end = forms.TimeField(label="Heure de fin", input_formats=("%H:%M",)) + begin = forms.TimeField(label="Heure de début", input_formats=("%H:%M",), + widget=TimeInput(attrs={"type": "time"})) + end = forms.TimeField(label="Heure de fin", input_formats=("%H:%M",), + widget=TimeInput(attrs={"type": "time"})) def __init__(self, *args, **kwargs): super(QSJPSForm, self).__init__(*args, **kwargs) -- cgit v1.2.1