How can I set a DateField format in django from the model?
As @bruno as mentioned in his answer, input_formats
is a forms field, however it can be used to control the date format saved from the model.
In settings.py
set DATE_INPUT_FORMATS
as below:
DATE_INPUT_FORMATS = ['%d-%m-%Y']
And in your form you could do something like below:
class ClientDetailsForm(ModelForm):
date_of_birth = DateField(input_formats=settings.DATE_INPUT_FORMATS)
class Meta:
model = ModelA
input_formats
is a forms.DateField
option, not a model.DateField
option. You have to set it in your form, not in your models.