'Change language of date. Django
I would like to know if there is a way to change the language of a date when we render it (the same way we can change the format: {{mydate|date:"d F Y - H:i"}}).
I looked at the doc : https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#date but i didn't find anything.
Thank you for your help.
Solution 1:[1]
You could change the locale before rendering it as a string. Then change it back after. Although, I'm not sure why you want to have a date in a language different from your other output. Maybe explain what you are trying to accomplish with this, first. There is no built-in way to do it simply formatting the date.
Solution 2:[2]
In django, you need change the language in you setting.py like that:
LANGUAGE_CODE = 'es-PE'
for this example, i'm from PerĂº.
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 | Furbeenator |
| Solution 2 | Luis Fernando Solis Navarro |
