Skip to content

Latest commit

 

History

History
44 lines (26 loc) · 1.32 KB

rss.rst

File metadata and controls

44 lines (26 loc) · 1.32 KB

RSS Feed

wagtailnews supports RSS feeds!

Custom RSS feed fields

wagtailnews support of RSS feeds comes from Django's syndication feed framework. Wagtail News provides a basic implementation, but you will need to customise it to suit your news models. For example, to add a custom <description> for your news items:

from wagtailnews.feeds import LatestEntriesFeed

class MyNewsFeed(LatestEntriesFeed):
    def item_description(self, item):
        return item.description

Your custom Feed class can then be added to your news index by setting the ~wagtailnews.models.NewsIndexMixin.feed_class attribute:

@newsindex
class NewsIndex(NewsIndexMixin, Page):
    feed_class = MyNewsFeed

Find out more about ~django.contrib.syndication.views.Feed classes in the Django docs: django:ref/contrib/syndication.

Linking to RSS feed

A link to the RSS feed can be created in a template like this:

{% load wagtailroutablepage_tags %}
<a href="{% routablepageurl page "feed" %}">RSS</a>

The Wagtail docs have more information on the ~wagtail.contrib.wagtailroutablepage.templatetags.wagtailroutablepage_tags.routablepageurl template tag.