Format Dates and Numbers
A snippet showing how to localize dates and numbers.
# settings.py (relevant)
USE_I18N = True
USE_L10N = True # enables localization of numbers/dates
USE_TZ = True
{% load l10n %}
{% load i18n %}
{% trans "Today is" %}: {{ today|date:"DATE_FORMAT" }}
{% trans "Total price" %}: {{ total_price|localize }}
{% trans "Unlocalized price" %}: {{ total_price|unlocalize }}
Explanation:
-
Use
|localize/|unlocalizefilters; useDATE_FORMAT,DATETIME_FORMAT. - Dates and numbers render according to the active locale and formatting settings.
- Category Internationalization (i18n)
- Total Views 111
- Last Modified 19 July, 2026
- Tags #i18n #formatting #localization #l10n
Previous snippet
Language Switcher in Templates
Next snippet