How can I change the default Django date template format?
Within your template, you can use Django's date
filter. E.g.:
<p>Birthday: {{ birthday|date:"M d, Y" }}</p>
Gives:
Birthday: Jan 29, 1983
More formatting examples in the date filter docs.
date
template tag
settings.DATE_FORMAT
Set both DATE_FORMAT
and USE_L10N
To make changes for the entire site in Django 1.4.1 add:
DATE_FORMAT = "Y-m-d"
to your settings.py
file and edit:
USE_L10N = False
since l10n overrides DATE_FORMAT
This is documented at: https://docs.djangoproject.com/en/dev/ref/settings/#date-format
Just use this:
{{you_date_field|date:'Y-m-d'}}
This will show something like 2016-10-16. You can use the format as you want.
You need a date template filter.
E.g:
<td>Joined {{user.date_created|date:"F Y" }}<td>
This returns Joined December 2018
.