您的代码中似乎存在许多问题:
在方法内 generate_web_content 你在创造一个 WebContent 通过传递参数对象 user_profile=self 虽然它应该是 blogger=self 。
generate_web_content
WebContent
user_profile=self
blogger=self
在方法中 _scan_web_content 你已经查询了所有的 Blogger 对象如:
_scan_web_content
Blogger
urls = Blogger.objects.all()
所以, urls 是一个queryset对象,你不能像访问密钥一样 urls['rss_url'] 相反,你应该这样做
urls
urls['rss_url']
d = feedparser.parse(self.rss_url)
在for循环中你应该添加属性 WebContent 对象作为参数传递,如:
for post in d.entries: web_content.blogger = self web_content.title = post.title.encode('ascii', 'ignore') web_content.url = post.link.encode('ascii', 'ignore') web_content.save()
否则这种方法什么都不做。
希望它澄清!