diff options
author | Alban Gruin | 2018-01-17 16:50:08 +0100 |
---|---|---|
committer | Alban Gruin | 2018-01-17 21:32:59 +0100 |
commit | 97f62a20f1716a9915358959b2e25912e8b17a90 (patch) | |
tree | c4ff9a4c3c45c663875906d2e024d08b103eaba4 | |
parent | d2a52ee6844d363ae020a49781b46402d7717a27 (diff) |
Utilisation des champs de formulaires date et time à la place de text
-rw-r--r-- | forms.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -14,17 +14,21 @@ # along with celcatsanitizer. If not, see <http://www.gnu.org/licenses/>. 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) |