Ticket #2987: syndication-feeds.diff
File syndication-feeds.diff, 2.2 KB (added by , 18 years ago) |
---|
-
syndication_feeds.txt
95 95 from django.contrib.syndication.feeds import Feed 96 96 from chicagocrime.models import NewsItem 97 97 98 class SiteNewsFeed(Feed):98 class LatestEntries(Feed): 99 99 title = "Chicagocrime.org site news" 100 100 link = "/sitenews/" 101 101 description = "Updates on changes and additions to chicagocrime.org." … … 120 120 put into those elements. 121 121 122 122 * To specify the contents of ``<title>`` and ``<description>``, create 123 `Django templates`_ called ``feeds/ sitenews_title.html`` and124 ``feeds/ sitenews_description.html``, where ``sitenews`` is the ``slug``123 `Django templates`_ called ``feeds/latest_title.html`` and 124 ``feeds/latest_description.html``, where ``latest`` is the ``slug`` 125 125 specified in the URLconf for the given feed. Note the ``.html`` extension 126 126 is required. The RSS system renders that template for each item, passing 127 127 it two template context variables: 128 128 129 129 * ``{{ obj }}`` -- The current object (one of whichever objects you 130 returned in ``items()``). 130 returned in ``items()``). 131 131 * ``{{ site }}`` -- A ``django.models.core.sites.Site`` object 132 132 representing the current site. This is useful for 133 133 ``{{ site.domain }}`` or ``{{ site.name }}``. … … 145 145 Both ``get_absolute_url()`` and ``item_link()`` should return the item's 146 146 URL as a normal Python string. 147 147 148 * For the LatestEntries example above, we could have very simple feed templates:: 149 150 * latest_title.html:: 151 152 {{ obj.title }} 153 154 * latest_description.html:: 155 156 {{ obj.description }} 157 158 .. _djangoproject.com feed templates: http://code.djangoproject.com/browser/djangoproject.com/django_website/templates/feeds 148 159 .. _chicagocrime.org: http://www.chicagocrime.org/ 149 160 .. _object-relational mapper: http://www.djangoproject.com/documentation/db_api/ 150 161 .. _Django templates: http://www.djangoproject.com/documentation/templates/