SelectDateWidget is very convenient but it normally seems to return dates in the format "%Y-%m-%d". It doesn't take a format parameter and doesn't have much documentation. Anyone run into this or have an idea how to work around it to get the output of the date into another format? There is this ticket, #6231 saying that there's a fix to have it use a DATE_FORMAT setting from settings.py (though I don't see why it can't just be given a format parameter also). There's a patch in the ticket from 2 months ago to implement this, so it seems I would have to get the latest dev version of django to use it, unless there is a way I can apply just this patch to my django install?
A:
Have you tried this setting yet ? According to the docs, it seems DATE_FORMAT=
has been a valid setting since version 1.0. Are you using a pre-1.0 version of django?
http://docs.djangoproject.com/en/1.0/ref/settings/#date-format
thornomad
2009-10-12 17:25:02
I tried it this morning with DATE_FORMAT="%m/%d/%Y" and it didn't seem to work. Perhaps I didn't bounce the server. I'll try it again tonight.
perrierism
2009-10-12 18:43:05
Actually, thinking twice about it, the fact that DATE_FORMAT has been in since 1.0 doesn't really suggest that it should work here. According to the ticket SelectDateWidget is only implemented to use it as of the patch mentioned in that ticket.
perrierism
2009-10-12 19:12:24
Yeah, that whole ticket http://code.djangoproject.com/ticket/6231 is about making SelectDateWidget work with the DATE_FORMAT setting. It doesn't currently, but apparently it does in the latest development version. The DATE_FORMAT documentation http://docs.djangoproject.com/en/dev/ref/settings/#date-format is pretty clear that it doesn't work with everything.
perrierism
2009-10-13 05:27:03
So the question still stands... How do I work around this? I'm not really interested in running the development version.
perrierism
2009-10-13 05:28:13
A:
The correct way to do this is with spaces rather than forward slashes i.e.
DATE_FORMAT = "%d %m %Y"
kerpunk
2010-09-21 10:09:31