'Format DateField model in Django
I used DateTime Field to format the date, but doesn't seem to work, what could be the isssue, below is my code :
from django.conf.locale.de import formats as de_formats
de_formats.DATE_FORMAT = 'd.m.Y'
This is the model :
contract_signed_on = models.DateField(
_('Contract signed on'), null=True, blank=True)
I want the date format to be like this :
04.3.2022
but it's not showing the exact format
Solution 1:[1]
Add DATE_INPUT_FORMATS in your settings.
DATE_INPUT_FORMATS = [
"%d.%m.%Y",
]
Django doc: https://docs.djangoproject.com/en/4.0/ref/settings/#date-input-formats
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gejun |
