2018-07-31 06:07:14 +00:00
|
|
|
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'),
|
2018-07-31 06:07:14 +00:00
|
|
|
}
|
|
|
|
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',)
|