Ticket #2987: syndication-feeds.diff

File syndication-feeds.diff, 2.2 KB (added by dev@…, 18 years ago)
  • syndication_feeds.txt

     
    9595    from django.contrib.syndication.feeds import Feed
    9696    from chicagocrime.models import NewsItem
    9797
    98     class SiteNewsFeed(Feed):
     98    class LatestEntries(Feed):
    9999        title = "Chicagocrime.org site news"
    100100        link = "/sitenews/"
    101101        description = "Updates on changes and additions to chicagocrime.org."
     
    120120put into those elements.
    121121
    122122    * To specify the contents of ``<title>`` and ``<description>``, create
    123       `Django templates`_ called ``feeds/sitenews_title.html`` and
    124       ``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``
    125125      specified in the URLconf for the given feed. Note the ``.html`` extension
    126126      is required. The RSS system renders that template for each item, passing
    127127      it two template context variables:
    128128
    129129          * ``{{ obj }}`` -- The current object (one of whichever objects you
    130             returned in ``items()``).
     130            returned in ``items()``). 
    131131          * ``{{ site }}`` -- A ``django.models.core.sites.Site`` object
    132132            representing the current site. This is useful for
    133133            ``{{ site.domain }}`` or ``{{ site.name }}``.
     
    145145      Both ``get_absolute_url()`` and ``item_link()`` should return the item's
    146146      URL as a normal Python string.
    147147
     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
    148159.. _chicagocrime.org: http://www.chicagocrime.org/
    149160.. _object-relational mapper: http://www.djangoproject.com/documentation/db_api/
    150161.. _Django templates: http://www.djangoproject.com/documentation/templates/
Back to Top