Edited docs/syndication_feeds.txt changes from [4982]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4988 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-04-09 15:48:08 +00:00
parent 13641ae92f
commit a02e13c7da
1 changed files with 16 additions and 13 deletions

View File

@ -114,10 +114,9 @@ Note:
`object-relational mapper`_, ``items()`` doesn't have to return model `object-relational mapper`_, ``items()`` doesn't have to return model
instances. Although you get a few bits of functionality "for free" by instances. Although you get a few bits of functionality "for free" by
using Django models, ``items()`` can return any type of object you want. using Django models, ``items()`` can return any type of object you want.
* If you are creating an Atom feed, rather than the default RSS feed, you * If you're creating an Atom feed, rather than an RSS feed, set the
will want to set the ``subtitle`` attribute instead of the ``subtitle`` attribute instead of the ``description`` attribute. See
``description`` attribute. See `Publishing Atom and RSS feeds in `Publishing Atom and RSS feeds in tandem`_, later, for an example.
tandem`_, later, for an example.
One thing's left to do. In an RSS feed, each ``<item>`` has a ``<title>``, One thing's left to do. In an RSS feed, each ``<item>`` has a ``<title>``,
``<link>`` and ``<description>``. We need to tell the framework what data to ``<link>`` and ``<description>``. We need to tell the framework what data to
@ -302,7 +301,7 @@ Publishing Atom and RSS feeds in tandem
--------------------------------------- ---------------------------------------
Some developers like to make available both Atom *and* RSS versions of their Some developers like to make available both Atom *and* RSS versions of their
feeds. That's easy to do with Django: Just create a subclass of your ``feed`` feeds. That's easy to do with Django: Just create a subclass of your ``Feed``
class and set the ``feed_type`` to something different. Then update your class and set the ``feed_type`` to something different. Then update your
URLconf to add the extra versions. URLconf to add the extra versions.
@ -322,16 +321,20 @@ Here's a full example::
class AtomSiteNewsFeed(RssSiteNewsFeed): class AtomSiteNewsFeed(RssSiteNewsFeed):
feed_type = Atom1Feed feed_type = Atom1Feed
subtitle = description subtitle = RssSiteNewsFeed.description
.. Note:: .. Note::
In Atom feeds, there is no feed-level description element. There *is* a In this example, the RSS feed uses a ``description`` while the Atom feed
subtitle element, however. Your RSS feed description may be too verbose uses a ``subtitle``. That's because Atom feeds don't provide for a
for a subtitle, so Django does not automatically put the feed description feed-level "description," but they *do* provide for a "subtitle."
into the subtitle element. Instead, you should create a ``subtitle``
attribute in your model, containing an appropriate string. In the above If you provide a ``description`` in your ``Feed`` class, Django will *not*
example, we have used the RSS feed's description, since it is quite short automatically put that into the ``subtitle`` element, because a subtitle
already. and description are not necessarily the same thing. Instead, you should
define a ``subtitle`` attribute.
In the above example, we simply set the Atom feed's ``subtitle`` to the
RSS feed's ``description``, because it's quite short already.
And the accompanying URLconf:: And the accompanying URLconf::