Python django.utils.feedgenerator.DefaultFeed() Examples

The following are 1 code examples of django.utils.feedgenerator.DefaultFeed(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.utils.feedgenerator , or try the search function .
Example #1
Source File: views.py    From rocket-league-replays with GNU General Public License v3.0 5 votes vote down vote up
def get(self, request):
        """Generates the RSS feed."""
        page = request.pages.current

        # Write the feed headers.
        feed = DefaultFeed(
            title=page.title,
            link=page.get_absolute_url(),
            description=page.meta_description,
        )

        # Write the feed items.
        for article in self.get_queryset()[:30]:
            feed.add_item(
                title=article.title,
                link=article.get_absolute_url(),
                description=process_html(
                    article.summary or article.content),
                pubdate=article.date,
            )

        # Write the response.
        content = feed.writeString("utf-8")
        response = HttpResponse(content)
        response["Content-Type"] = feed.mime_type
        response["Content-Length"] = len(content)

        return response