A
A
Anton Manevant2014-11-11 13:25:06
Django
Anton Manevant, 2014-11-11 13:25:06

How to create one rss feed from many models?

I don't know how to solve this problem.
django 1.7
I create a standard rss feed using the standard django.contrib.syndication.views.Feed functionality.
When accessing the /rss address, it is necessary to give a feed from several models.
rss.py code where we create a feed class with 10 latest article entries.

class ArticleFeed(Feed):
    feed_type = Rss201rev2Feed
    title = "All last article feed"
    link = "/articles/"
    description = "Все новые статьи."
    def items(self):
        articles = Article.objects.order_by('-created')[:10]
        return articles
    def item_title(self, item):
        return item.title

    def item_description(self, item):
        return item.preview

    def item_link(self, item):
        return reverse('article_show', args=[item.pk, item.slug])

And the url.py binding code
from somewhere.rss import ArticleFeed

    ...
    url(r'^feed/$', ArticleFeed()),

Question - how to display several Feed objects at one url /rss? For example, even NewsFeed?
Duplicate Querysets? Is there a standard solution to this problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question