【发布时间】:2010-12-02 14:04:29
【问题描述】:
我有以下问题。
项目的django-piston api的handlers.py:
....
# "need" to set this for datetime.strftime()
locale.setlocale(locale.LC_TIME,'de_AT.UTF-8')
class ItemOverviewHandler(BaseHandler):
...
@classmethod
def date(self, item):
# because of the setlocale() call the datestring is in german
# that's good
return item.somedatefield.date.strftime("%d. %B %Y")
...
现在看来这会影响项目的提要(使用 django.contrib.syndication 创建):
def item_pubdate(self, item):
return item.pub_date #datetime field
# the rss look's like this
# that's not good
<pubDate>Die, 17 Aug 2010 14:00:00 +0200</pubDate>
(这是一个 rfc 符合日期,但在德语中 Die == Dienstag == Tuesday),因此它是无效的。
所以我需要活塞 API 响应为德语(完成)。但是提要的 pubDate 必须是英文的(不知道如何做到这一点)。
有什么建议吗?
【问题讨论】:
标签: python django datetime localization django-piston