Date format for django SelectDateWidget

SelectDateWidget is very convenient, but usually returns dates in the format "% Y-% m-% d". It does not accept a format parameter and does not have much documentation. Does anyone come across this or have an idea how to get around it to get the date output in a different format? There is this ticket, # 6231 , which says that there is a fix for it to use the DATE_FORMAT parameter from settings.py (although I don’t see why it also cannot be given a format parameter). There was a patch on the ticket from 2 months ago to implement this, so it seems to me that I will need to use the latest version of django dev in order to use it, unless there is a way to apply this patch to the django installation?

+3
source share
3 answers

DATE_FORMAT works with SelectDateWidget, but you should use format strings without percent (as used in: now the template tag ) as follows:

DATE_FORMAT = 'j N Y'
+2
source

Have you tried this setting? According to the docs, it seems to be DATE_FORMAT=a valid parameter since version 1.0. Are you using django version prior to version 1.0?

http://docs.djangoproject.com/en/1.0/ref/settings/#date-format

0
source

- , , ..

DATE_FORMAT = "%d %m %Y"
-1

Source: https://habr.com/ru/post/1719882/


All Articles