[Fixed]-How to use a localized "short format" when formatting dates in Django?

32👍

Yes, there is SHORT_DATE_FORMAT.

In a template, it is possible to use it with the date filter:

{{ your_date_value|date:"SHORT_DATE_FORMAT" }}

Outside of a template, it is possible to use django.utils.formats.date_format, as so:

from django.utils.formats import date_format
date_format(date_obj, format='SHORT_DATE_FORMAT', use_l10n=True)
👤jpic

Leave a comment