1
I am unable to change the Django configuration so that the date format looks like’d/m/Y'. In the form validation, if you enter 22/12/1980, the form is invalid. Informing 12/22/1980 the field date is valid and I can save the record.
I have tried to change the following settings:
py Settings.
LANGUAGE_CODE = 'pt-br'
USE_L10N = False
In the class, the attribute is set to:
data_nascimento = models.DateField(null=False)
Is there any other setting so I can change the date format from’m/d/Y' to’d/m/Y'?
Already tried using configuration
DATE_FORMAT
?– Woss
Not yet, where should I inform DATE_FORMAT, in Settings.py? Would DATE_FORMAT = ’d/m/Y'?
– Developer
@Anderson I included in Settings.py, but I still have an error in the validation "data_nascimento Enter a valid date.". What would be the right place to inform DATE_FORMAT? Thank you.
– Developer
Yes, it’s in the
settings.py
. TryDATE_FORMAT = "%d/%m/%Y"
, or put this format inDATE_INPUT_FORMAT = ["%d/%m/%Y"]
.– Woss
@Andreson Includes DATE_FORMAT and DATE_INPUT_FORMAT in Settings.py, but I still have the bug.
– Developer
I printed the form, the value is being passed correctly to view: <tr><th><label for="id_data_birth">Date of birth:</label></th><td><ul class="errorlist"><li>Enter a valid date. </li></ul><input type="text" name="data_nascimento" value="12/22/2005" required id="id_data_nascimento" /></td></tr>
– Developer
Anderson, I got it. You’re correct, you just missed an "S" on DATE_INPUT_FORMATS. Can you reply so I can mark your reply? Thank you very much.
– Developer