Format localization
To enhance user experience, it’s important to present dates, times, and numbers in formats that align with the user’s locale. Adapting your site to the data formats familiar to users in various regions significantly improves its accessibility. Since Django 5.0, localized formatting of data is always enabled. Django displays numbers and dates using the format of the current locale.
Django tries to use a locale-specific format whenever it outputs a value in a template. Figure 11.16 shows the format localization for decimal numbers in the English and Spanish versions of the site:
Figure 11.16: Format localization in English and Spanish
Decimal numbers in the English version are displayed with a dot separator for decimal places, while in the Spanish version, a comma is used as the separator. This is due to the locale formats specified for the en
and es
locales by Django. You can take a look at the English formatting configuration at https...