Django

RSS in Django

RSS in Django

Django also supports a syndication feed-generating framework that you can use to create an RSS feed. To do that, you need to subclass the feed class using the code below:

django.contrib.syndication.views.Feed Here, we will create a feed in the firstapp/feeds.py file and also provide a description of our feed:

firstapp / feeds.py
from django.contrib.syndication.views import Feed
from django.contrib.comments import Comment
from django.core.urlresolvers import reverse
class RssFeed(Feed):
title_name = “RSS Feed in Django”
link = “/django-comments/”
des = “Here we will add a description for our feed.”
def rss(self):
return Comment.objects.all().order_by(“-submit_date”) [:5]
def rss_title(self, rss):
return rss.u_name
def rss_des(self, rss):
return rss.comment
def rss_link(self, rss):
return reverse (‘comment’, kwargs = {‘object_pk’:rss.pk})

 

This way, you can create an RSS feed in Django. 

Top course recommendations for you

    Docker Swarm Project
    1 hrs
    Beginner
    819 Learners
    4.55  (22)
    Collections in Java
    3 hrs
    Beginner
    4.5K+ Learners
    4.59  (150)
    PyCharm for Beginners
    1 hrs
    Beginner
    2.7K+ Learners
    4.41  (136)
    Git Tutorial
    2 hrs
    Beginner
    10.2K+ Learners
    4.53  (699)
    Create a IPL theme Landing page with CSS and HTML
    1 hrs
    Beginner
    6.8K+ Learners
    4.3  (297)
    PyTest Basics
    2 hrs
    Beginner
    2.7K+ Learners
    4.41  (132)
    Python MySQL
    1 hrs
    Beginner
    11.5K+ Learners
    4.51  (480)
    Python Automation Project
    2 hrs
    Beginner
    6.7K+ Learners
    4.57  (209)
    Python For Android
    2 hrs
    Beginner
    5.2K+ Learners
    4.5  (109)
    Kivy Projects
    2 hrs
    Beginner
    1.8K+ Learners
    4.48  (52)