1👍
You need just to override Django’s defaults locale settings. Add this to your settings.py file
from django.conf.locale.es import formats as es_formats
es_formats.DATETIME_FORMAT = "d M Y H:i:s"
1👍
fahim kazi was right: to define a models.DateField format, you need DATE_FORMAT, not DATETIME_FORMAT.
Yet Naveen Varshney was also right: not DATE_FORMAT nor DATETIME_FORMAT work without specifying the language, with es_formats for instance.
Therefore, from the combination of both answers, put the following in settings:
es_formats.DATE_FORMAT = 'd-m-y'
(Also '%d-%m-%y'
printed %01-%08-%20
thus the %
is not needed).
Thanks both.
- [Django]-Descriptor 'date' requires a 'datetime.datetime' object but received a 'unicode'
- [Django]-In Django Admin, I want to change how foreign keys are displayed in a Many-Many Relationship admin widget
- [Django]-ImportError: module incorrectly imported
- [Django]-Django REST Framework ObtainAuthToken User Login Api view
0👍
- [Django]-Django. Get only current day. Only day without time
- [Django]-Django : authenticate() is not working for users created by register page, but working for those users who were created by admin
- [Django]-Django testing with local settings
Source:stackexchange.com