Django联合功能错误

时间:2017-12-04 15:05:24

标签: python django wagtail django-syndication

我正在尝试使用django syndication创建自定义Django RSS Feed(实际上使用django wagtail feeds)。我有一个错误,我认为我已经确定它来自一个NoneType对象,该对象由Result : Table1Id item Dimensions Description 1 test1 10*11*12 Test element1 desc 1 2 test2 13*14*15 Test element2 desc 1 内的get_object()函数返回。

`/ feed / basic / Chups /的AttributeError 'NoneType'对象没有'startswith'属性

例外位置:/Users/technical/.virtualenvs/wagtest4-plnzODoN/lib/python3.6/site-packages/django/contrib/syndication/views.py in add_domain,第19行

该函数作为syndication/views.py的一部分调用,如下所示:

class Feed()

该函数在第36行调用但由于def get_object(self, request, *args, **kwargs): return None 返回get_object()对象而失败。

我对django wagtail feed的自定义以下列方式扩展None

Feed

from django.contrib.syndication.views import Feed from django.utils.feedgenerator import ( SyndicationFeed, rfc3339_date, Rss201rev2Feed ) from .models import RSSFeedsSettings, RSSFeed class BasicFeed(Feed): # FEED TYPE feed_type = Rss201rev2Feed def get_object(self, request, category): return category try: feed_app_settings = RSSFeedsSettings.objects.get(feed_category_name="Flex") print(feed_app_settings) feed_app_label = feed_app_settings.feed_app_label feed_model_name = feed_app_settings.feed_model_name feed_category_name = feed_app_settings.feed_category_name use_feed_image = feed_app_settings.feed_image_in_content except: # pragma: no cover feed_app_settings = None try: feed_model = apps.get_model(app_label=feed_app_label, model_name=feed_model_name) except: # pragma: no cover feed_model = None # The RSS information that gets shown at the top of the feed. if feed_app_settings is not None: title = feed_app_settings.feed_title link = feed_app_settings.feed_link description = feed_app_settings.feed_description author_email = feed_app_settings.feed_author_email author_link = feed_app_settings.feed_author_link item_description_field = feed_app_settings.feed_item_description_field item_content_field = feed_app_settings.feed_item_content_field def items(self, obj): url_category = obj categories = ContentType(app_label="blog", model="blogcategory") category_id = categories.get_object_for_this_type(name=url_category).id return feed_model.objects.filter(categories=category_id).order_by('-date').live() def item_pubdate(self, item): return datetime.combine(item.date, time()) def item_link(self, item): return item.full_url def item_author_name(self, item): pass 包含此内容,请求似乎正常运行。

urls.py

任何人都可以告诉我为什么会这样吗?我错过了关于这个预期功能的一些事情。谢谢!

0 个答案:

没有答案