Reputation: 952
The HTML5 input datetime-local returns it's value in %Y-%m-%dT%H:%M format. Notice the T between the day and hour. I've added that to the field in the form like this:
end = forms.DateTimeField(required=True, input_formats='%Y-%m-%dT%H:%M')
and the template manually creates the field:
<input type="datetime-local" id="id_end" name="end" value="{{ form.end.value }}">
Inspection of the request reveals the form data does indeed send the field in a format matching the validator: 2016-04-06T17:18
So what is the format validator returning a validation failure?
Upvotes: 4
Views: 3005
Reputation: 25539
I think input_formats
parameter is a list not a string(as the name implies). Please check the django doc about DateTimeField input_formats.
input_formats
A list of formats used to attempt to convert a string to a valid datetime.date object.
Upvotes: 4