mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
Fixed #2987: cleaned up the syndication documentation a bit, thanks to dev@simon.net.nz.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4031 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
644af2213d
commit
09d40c508a
@ -95,7 +95,7 @@ latest five news items::
|
|||||||
from django.contrib.syndication.feeds import Feed
|
from django.contrib.syndication.feeds import Feed
|
||||||
from chicagocrime.models import NewsItem
|
from chicagocrime.models import NewsItem
|
||||||
|
|
||||||
class SiteNewsFeed(Feed):
|
class LatestEntries(Feed):
|
||||||
title = "Chicagocrime.org site news"
|
title = "Chicagocrime.org site news"
|
||||||
link = "/sitenews/"
|
link = "/sitenews/"
|
||||||
description = "Updates on changes and additions to chicagocrime.org."
|
description = "Updates on changes and additions to chicagocrime.org."
|
||||||
@ -120,14 +120,14 @@ One thing's left to do. In an RSS feed, each ``<item>`` has a ``<title>``,
|
|||||||
put into those elements.
|
put into those elements.
|
||||||
|
|
||||||
* To specify the contents of ``<title>`` and ``<description>``, create
|
* To specify the contents of ``<title>`` and ``<description>``, create
|
||||||
`Django templates`_ called ``feeds/sitenews_title.html`` and
|
`Django templates`_ called ``feeds/latest_title.html`` and
|
||||||
``feeds/sitenews_description.html``, where ``sitenews`` is the ``slug``
|
``feeds/latest_description.html``, where ``latest`` is the ``slug``
|
||||||
specified in the URLconf for the given feed. Note the ``.html`` extension
|
specified in the URLconf for the given feed. Note the ``.html`` extension
|
||||||
is required. The RSS system renders that template for each item, passing
|
is required. The RSS system renders that template for each item, passing
|
||||||
it two template context variables:
|
it two template context variables:
|
||||||
|
|
||||||
* ``{{ obj }}`` -- The current object (one of whichever objects you
|
* ``{{ obj }}`` -- The current object (one of whichever objects you
|
||||||
returned in ``items()``).
|
returned in ``items()``).
|
||||||
* ``{{ site }}`` -- A ``django.models.core.sites.Site`` object
|
* ``{{ site }}`` -- A ``django.models.core.sites.Site`` object
|
||||||
representing the current site. This is useful for
|
representing the current site. This is useful for
|
||||||
``{{ site.domain }}`` or ``{{ site.name }}``.
|
``{{ site.domain }}`` or ``{{ site.name }}``.
|
||||||
@ -145,6 +145,16 @@ put into those elements.
|
|||||||
Both ``get_absolute_url()`` and ``item_link()`` should return the item's
|
Both ``get_absolute_url()`` and ``item_link()`` should return the item's
|
||||||
URL as a normal Python string.
|
URL as a normal Python string.
|
||||||
|
|
||||||
|
* For the LatestEntries example above, we could have very simple feed templates:
|
||||||
|
|
||||||
|
* latest_title.html::
|
||||||
|
|
||||||
|
{{ obj.title }}
|
||||||
|
|
||||||
|
* latest_description.html::
|
||||||
|
|
||||||
|
{{ obj.description }}
|
||||||
|
|
||||||
.. _chicagocrime.org: http://www.chicagocrime.org/
|
.. _chicagocrime.org: http://www.chicagocrime.org/
|
||||||
.. _object-relational mapper: http://www.djangoproject.com/documentation/db_api/
|
.. _object-relational mapper: http://www.djangoproject.com/documentation/db_api/
|
||||||
.. _Django templates: http://www.djangoproject.com/documentation/templates/
|
.. _Django templates: http://www.djangoproject.com/documentation/templates/
|
||||||
|
Loading…
Reference in New Issue
Block a user