In a Django ModelForm's DateTimeField I want to have an input_format
that accepts a datetime with milliseconds. e.g. '2018-02-26T14:46:15.704Z'
. But strftime
only has %f
for microseconds. How do I add an input_format
to cope with this format?
My field so far:
class MyModelForm(forms.ModelForm):
my_time = forms.DateTimeField(input_formats=['%Y-%m-%dT%H:%M:%S.%fZ',])
This will match:
'2018-02-26T14:46:15.000704Z'
but not:
'2018-02-26T14:46:15.704Z'