def add_new_posts(last_updated=None): """Run this on a cron""" for blog in Blog.objects.all(): try: document = feedparser.parse(blog.feed_url) except: print "error parsing" continue if last_updated is None: print("- Adding %i articles from %s" % (len(document['entries']), blog.title)) for entry in document['entries']: # now we create a new post post = Post() post.blog = blog post.title = entry['title'] if 'summary' in entry: post.content = entry['summary'] if 'content' in entry: post.content = entry['content'] post.link = entry['link'] post.save() else: # TODO: only parse from a date pass