From 32416d6b8f9d990cba5490ec96d5744869dc6d76 Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Wed, 17 May 2017 21:29:46 -0600 Subject: [PATCH] Allow more date formats (#47) * Update moment version. * Add more allowable date formats. * Field should not be required. --- bikeshop_project/registration/forms.py | 8 ++++++-- .../registration/templates/edit_member_form.html | 5 +++-- bikeshop_project/registration/templates/member_form.html | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bikeshop_project/registration/forms.py b/bikeshop_project/registration/forms.py index 0ba295a..51bc6f1 100644 --- a/bikeshop_project/registration/forms.py +++ b/bikeshop_project/registration/forms.py @@ -1,11 +1,16 @@ -from django.forms import ModelForm, EmailInput, TextInput, DateInput, CheckboxInput, BooleanField, Textarea +from django.forms import ModelForm, EmailInput, TextInput, DateInput, CheckboxInput, BooleanField, Textarea, DateField from django.utils import timezone from registration.models import Member class MemberForm(ModelForm): + input_formats = ['%Y-%m-%d', '%y-%m-%d', '%d-%m-%y', '%d-%m-%Y', + '%Y/%m/%d', '%y/%m/%d', '%d/%m/%y', '%d/%m/%Y'] + waiver_substitute = BooleanField(required=False, label='I have read and agree to the above terms & conditions.', widget=CheckboxInput(attrs={'class': 'mdl-checkbox__input'})) + date_of_birth = DateField(required=False, input_formats=input_formats, + widget=DateInput(attrs={'class': 'mdl-textfield__input'})) class Meta: model = Member @@ -20,7 +25,6 @@ class MemberForm(ModelForm): 'first_name': TextInput(attrs={'class': 'mdl-textfield__input'}), 'last_name': TextInput(attrs={'class': 'mdl-textfield__input'}), 'preferred_name': TextInput(attrs={'class': 'mdl-textfield__input'}), - 'date_of_birth': DateInput(attrs={'class': 'mdl-textfield__input'}), 'guardian_name': DateInput(attrs={'class': 'mdl-textfield__input', 'disabled': 'disabled'}), 'phone': TextInput(attrs={'class': 'mdl-textfield__input', 'pattern': '[0-9]*'}), 'street': TextInput(attrs={'class': 'mdl-textfield__input'}), diff --git a/bikeshop_project/registration/templates/edit_member_form.html b/bikeshop_project/registration/templates/edit_member_form.html index 50d2bc1..19e68ef 100644 --- a/bikeshop_project/registration/templates/edit_member_form.html +++ b/bikeshop_project/registration/templates/edit_member_form.html @@ -2,7 +2,7 @@ {% load staticfiles %} {% block scripts %} - + +