Hi,
I'm using Django to serve up some XML. Part of the requirements is that my dates are formatted as follows: 1969-12-31T18:33:28-06:00
How can I output a DateField in Django in that format?
Hi,
I'm using Django to serve up some XML. Part of the requirements is that my dates are formatted as follows: 1969-12-31T18:33:28-06:00
How can I output a DateField in Django in that format?
Check out these docs:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#date http://docs.djangoproject.com/en/dev/ref/settings/#setting-DATE_FORMAT http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ttag-now
This should be enough for you to format your date any way, you wish.
If you look under date in the Django documentation you'll see that a variety of formats for the date are supported. Basically in a template you would do
{{ value|date "some format string" }}
where the format string can be one of the ones defined under date on the page above or one of the custom ones defined under the now function (which includes ISO 8601 format) which is also on the page linked to above. I'm assuming that when you output to xml you do so in a similar way to a template for a normal web page.
Since Django is written in Python,
http://docs.python.org/library/datetime.html#datetime.datetime.isoformat