Changeset 1197
- Timestamp:
- 11/11/05 22:00:35 (3 years ago)
- Files:
-
- django/trunk/docs/syndication_feeds.txt (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/syndication_feeds.txt
r1196 r1197 90 90 ---------------- 91 91 92 This simple example, taken from chicagocrime.org, describes a feed of the92 This simple example, taken from `chicagocrime.org`_, describes a feed of the 93 93 latest five news items:: 94 94 … … 133 133 134 134 If you don't create a template for either the title or description, the 135 framework will use the template `` {{ obj }}`` by default -- that is, the136 normal string representation of the object.135 framework will use the template ``"{{ obj }}"`` by default -- that is, 136 the normal string representation of the object. 137 137 * To specify the contents of ``<link>``, you have two options. For each 138 138 item in ``items()``, Django first tries executing a … … 143 143 URL as a normal Python string. 144 144 145 .. _chicagocrime.org: http://www.chicagocrime.org/ 145 146 .. _object-relational mapper: http://www.djangoproject.com/documentation/db_api/ 146 147 .. _Django templates: http://www.djangoproject.com/documentation/templates/ … … 151 152 The framework also supports more complex feeds, via parameters. 152 153 153 For example, chicagocrime.orgoffers an RSS feed of recent crimes for every154 For example, `chicagocrime.org`_ offers an RSS feed of recent crimes for every 154 155 police beat in Chicago. It'd be silly to create a separate ``Feed`` class for 155 156 each police beat; that would violate the `DRY principle`_ and would couple data 156 to programming logic. Instead, the RSS framework lets you make generic feeds157 that output items based on information in the feed's URL.157 to programming logic. Instead, the syndication framework lets you make generic 158 feeds that output items based on information in the feed's URL. 158 159 159 160 On chicagocrime.org, the police-beat feeds are accessible via URLs like this: … … 162 163 * ``/rss/beats/1424/`` -- Returns recent crimes for beat 1424. 163 164 164 The slug here is `` beats``. The syndication framework sees the extra URL bits165 The slug here is ``"beats"``. The syndication framework sees the extra URL bits 165 166 after the slug -- ``0613`` and ``1424`` -- and gives you a hook to tell it what 166 167 those URL bits mean, and how they should influence which items get published in … … 208 209 ``get_object()`` tells Django to produce a 404 error for that request. 209 210 * To generate the feed's ``<title>``, ``<link>`` and ``<description>``, 210 Django uses the ``title ``, ``link`` and ``description`` methods. In the211 previous example, they were simple string class attributes, but this211 Django uses the ``title()``, ``link()`` and ``description()`` methods. In 212 the previous example, they were simple string class attributes, but this 212 213 example illustrates that they can be either strings *or* methods. For 213 214 each of ``title``, ``link`` and ``description``, Django follows this … … 243 244 Note that you set ``feed_type`` to a class object, not an instance. 244 245 245 Currently available feed types are: :246 Currently available feed types are: 246 247 247 248 * ``django.utils.feedgenerator.Rss201rev2Feed`` (RSS 2.01. Default.) … … 500 501 They share this interface: 501 502 502 ``__init__(title, link, description, language=None, author_email=None, 503 author_name=None, author_link=None, subtitle=None, categories=None)``503 ``__init__(title, link, description, language=None, author_email=None,`` 504 ``author_name=None, author_link=None, subtitle=None, categories=None)`` 504 505 505 506 Initializes the feed with the given metadata, which applies to the entire feed … … 509 510 which should be a sequence of Unicode objects. 510 511 511 ``add_item(title, link, description, author_email=None, author_name=None, 512 pubdate=None, comments=None, unique_id=None, enclosure=None, categories=())``512 ``add_item(title, link, description, author_email=None, author_name=None,`` 513 ``pubdate=None, comments=None, unique_id=None, enclosure=None, categories=())`` 513 514 514 515 Add an item to the feed with the given parameters. All parameters, if given, 515 516 should be Unicode objects, except: 516 517 517 * ``pubdate`` should be a Python datetime object.518 * ``pubdate`` should be a `Python datetime object`_. 518 519 * ``enclosure`` should be an instance of ``feedgenerator.Enclosure``. 519 520 * ``categories`` should be a sequence of Unicode objects. … … 551 552 552 553 .. _django/utils/feedgenerator.py: http://code.djangoproject.com/browser/django/trunk/django/utils/feedgenerator.py 554 .. _Python datetime object: http://www.python.org/doc/current/lib/module-datetime.html
