1👍
✅
There seem to be many problems in your code:
-
Within the method
generate_web_content
you are creating aWebContent
object by passing the argumentuser_profile=self
while it should beblogger=self
. -
In the method
_scan_web_content
you’ve queried all theBlogger
objects like:urls = Blogger.objects.all()
so,
urls
is a queryset object and you can’t access the key likeurls['rss_url']
instead you should dod = feedparser.parse(self.rss_url)
-
Inside the for loop you should add attributes to the
WebContent
object passed as an argument like: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()
otherwise this method does not do anything.
Hope it clarifies!
Source:stackexchange.com