Simple Django template question
I have a template variable:
{{article.pub_date}}
that outputs this:
May 25, 开发者_如何学Python2011, 7:52 p.m.
How can I get just the date without the time:
May 25, 2011
without the:
, 7:52 p.m.
I only have access to the template tags/variables not the python code.
{{ article.pub_date|date:"DATE_FORMAT" }}
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
{{article.pub_date|date:"F j, Y"}}
Django uses the same formatting as PHP date objects.
Also you can set a default format if you want a format used all over the site
https://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#date-format
精彩评论