How it works...

If you have some data in the database and you open http://127.0.0.1:8000/bulletin-board/rss/?bulletin_type=offering&category=4 in your browser, you will get an RSS feed of bulletins with the Offering type and the category ID of 4. The Feed class takes care of automatically generating the XML markup for the RSS feed.

The BulletinFeed class has the get_objects() method that takes the current HttpRequest and defines the obj dictionary used in other methods of the same class. The obj dictionary contains the bulletin type, the category, and the current query string.

The title() method returns the title of the feed. It can either be generic or related to the selected bulletin type or category. The link() method returns the link to the original bulletin list with the filtering done. The feed_url() method returns the URL of the current feed. The items() method does the filtering itself and returns a filtered QuerySet of bulletins. Finally, the item_pubdate() method returns the creation date of the bulletin.

To see all the available methods and properties of the Feed class that we are extending, refer to the following documentation at https://docs.djangoproject.com/en/2.1/ref/contrib/syndication/#feed-class-reference.

The other parts of the code are self-explanatory.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.135.224