essensplan/cal/forms.py

17 lines
528 B
Python
Raw Normal View History

from django.forms import ModelForm, DateInput
from cal.models import Event
class EventForm(ModelForm):
class Meta:
model = Event
# datetime-local is a HTML5 input type, format to make date time show on fields
widgets = {
2020-05-16 19:06:08 +00:00
'date': DateInput(format='%Y-%m-%d'),
}
fields = '__all__'
def __init__(self, *args, **kwargs):
super(EventForm, self).__init__(*args, **kwargs)
# input_formats parses HTML5 datetime-local input to datetime field
2020-05-16 19:06:08 +00:00
self.fields['date'].input_formats = ('%Y-%m-%d',)