~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to docs/ref/contrib/syndication.txt

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-10-12 11:34:35 UTC
  • mfrom: (1.2.7 upstream)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: james.westby@ubuntu.com-20101012113435-9lnsrh0i3mxozbt0
Tags: upstream-1.2.3
ImportĀ upstreamĀ versionĀ 1.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.. _ref-contrib-syndication:
2
 
 
3
1
==============================
4
2
The syndication feed framework
5
3
==============================
38
36
The high-level feed-generating framework is supplied by the
39
37
:class:`~django.contrib.syndication.views.Feed` class. To create a
40
38
feed, write a :class:`~django.contrib.syndication.views.Feed` class
41
 
and point to an instance of it in your :ref:`URLconf
42
 
<topics-http-urls>`.
 
39
and point to an instance of it in your :doc:`URLconf
 
40
</topics/http/urls>`.
43
41
 
44
42
Feed classes
45
43
------------
54
52
They can live anywhere in your codebase.
55
53
 
56
54
Instances of :class:`~django.contrib.syndication.views.Feed` classes
57
 
are views which can be used in your :ref:`URLconf <topics-http-urls>`.
 
55
are views which can be used in your :doc:`URLconf </topics/http/urls>`.
58
56
 
59
57
A simple example
60
58
----------------
80
78
            return item.description
81
79
 
82
80
To connect a URL to this feed, put an instance of the Feed object in
83
 
your :ref:`URLconf <topics-http-urls>`. For example::
 
81
your :doc:`URLconf </topics/http/urls>`. For example::
84
82
 
85
83
    from django.conf.urls.defaults import *
86
84
    from myproject.feeds import LatestEntriesFeed
102
100
* :meth:`items()` is, simply, a method that returns a list of objects that
103
101
  should be included in the feed as ``<item>`` elements. Although this
104
102
  example returns ``NewsItem`` objects using Django's
105
 
  :ref:`object-relational mapper <ref-models-querysets>`, :meth:`items()`
 
103
  :doc:`object-relational mapper </ref/models/querysets>`, :meth:`items()`
106
104
  doesn't have to return model instances. Although you get a few bits of
107
105
  functionality "for free" by using Django models, :meth:`items()` can
108
106
  return any type of object you want.
123
121
      both.
124
122
 
125
123
      If you want to do any special formatting for either the title or
126
 
      description, :ref:`Django templates <topics-templates>` can be used
 
124
      description, :doc:`Django templates </topics/templates>` can be used
127
125
      instead. Their paths can be specified with the ``title_template`` and
128
126
      ``description_template`` attributes on the
129
127
      :class:`~django.contrib.syndication.views.Feed` class. The templates are
167
165
:class:`~django.contrib.syndication.views.Feed` class for each police beat; that
168
166
would violate the :ref:`DRY principle <dry>` and would couple data to
169
167
programming logic. Instead, the syndication framework lets you access the
170
 
arguments passed from your :ref:`URLconf <topics-http-urls>` so feeds can output
 
168
arguments passed from your :doc:`URLconf </topics/http/urls>` so feeds can output
171
169
items based on information in the feed's URL.
172
170
 
173
171
On chicagocrime.org, the police-beat feeds are accessible via URLs like this:
175
173
    * :file:`/beats/613/rss/` -- Returns recent crimes for beat 613.
176
174
    * :file:`/beats/1424/rss/` -- Returns recent crimes for beat 1424.
177
175
 
178
 
These can be matched with a :ref:`URLconf <topics-http-urls>` line such as::
 
176
These can be matched with a :doc:`URLconf </topics/http/urls>` line such as::
179
177
 
180
178
    (r'^beats/(?P<beat_id>\d+)/rss/$', BeatFeed()),
181
179