【问题标题】:Correct timezone for Django RSS syndication frameworkDjango RSS 联合框架的正确时区
【发布时间】:2014-01-22 21:41:09
【问题描述】:

我通过documentation 在我的 django 项目中设置了 RSS 提要

但看起来<lastBuildDate>Thu, 23 Jan 2014 10:23:31 -0000</lastBuildDate> 上的时间戳没有给出正确的时间偏移量,应该是 +13 小时。

我的设置是:

TIME_ZONE = 'Pacific/Auckland'

LANGUAGE_CODE = 'en-nz'

USE_I18N = True

USE_L10N = True

USE_TZ = True

【问题讨论】:

    标签: django timezone


    【解决方案1】:

    看来我需要在类中定义 item_pubdate 函数:

    from articles.models import Story
    from django.contrib.syndication.views import Feed
    from django.contrib.sites.models import Site
    
    current_site = Site.objects.get_current()
    .
    class LatestStoriesFeed(Feed):
        title = 'Latest stories'
        link = "/" 
    
        def items(self):
            return Story.active_objects.filter(sites__in=[current_site])[:10]
    ....
        def item_title(self, item):
            return item.title
    
        def item_descrpition(self, item):
            return item.introtext
    
        def item_link(self, item):
            return item.get_absolute_url()
    
        def item_pubdate(self, item):
            return item.publish_date
    

    【讨论】:

      猜你喜欢
      • 2011-10-28
      • 1970-01-01
      • 1970-01-01
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-27
      相关资源
      最近更新 更多