django feeds 的发布日期错误
我有以下问题。
项目的 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.syndicate 创建):(
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 必须是英文(不知道如何实现这一点)。
有什么建议吗?
I have following problem.
handlers.py of project's django-piston api:
....
# "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")
...
now it seems like this effects the project's feeds (created with 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>
(this is an rfc conform date, BUT in german Die == Dienstag == Tuesday), thus it's invalid.
So I need the piston api response to be in german (done). but pubDate of the feed has to be in english (have no idea how to accomplish this).
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这成功了。但我仍然愿意接受其他建议:)
this did the trick. but im still open for other suggestions :)
您可以使用 Babel 国际化模块。请在此处查找用于格式化日期时间的
format_date
函数特定区域设置。You could use the Babel internationalization module. Look here for the
format_date
function that formats datetime with a specific locale.