Changeset 3214
- Timestamp:
- 06/26/06 18:19:03 (2 years ago)
- Files:
-
- django/trunk/django/contrib/syndication/feeds.py (modified) (3 diffs)
- django/trunk/docs/syndication_feeds.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/syndication/feeds.py
r3143 r3214 17 17 item_enclosure_url = None 18 18 feed_type = feedgenerator.DefaultFeed 19 title_template = None 20 description_template = None 19 21 20 22 def __init__(self, slug, feed_url): 21 23 self.slug = slug 22 24 self.feed_url = feed_url 25 self.title_template_name = self.title_template or ('feeds/%s_title.html' % slug) 26 self.description_template_name = self.description_template or ('feeds/%s_description.html' % slug) 23 27 24 28 def item_link(self, item): … … 78 82 79 83 try: 80 title_t emplate = loader.get_template('feeds/%s_title.html' % self.slug)84 title_tmp = loader.get_template(self.title_template_name) 81 85 except TemplateDoesNotExist: 82 title_t emplate= Template('{{ obj }}')86 title_tmp = Template('{{ obj }}') 83 87 try: 84 description_t emplate = loader.get_template('feeds/%s_description.html' % self.slug)88 description_tmp = loader.get_template(self.description_template_name) 85 89 except TemplateDoesNotExist: 86 description_t emplate= Template('{{ obj }}')90 description_tmp = Template('{{ obj }}') 87 91 88 92 for item in self.__get_dynamic_attr('items', obj): … … 103 107 author_email = author_link = None 104 108 feed.add_item( 105 title = title_t emplate.render(Context({'obj': item, 'site': current_site})).decode('utf-8'),109 title = title_tmp.render(Context({'obj': item, 'site': current_site})).decode('utf-8'), 106 110 link = link, 107 description = description_t emplate.render(Context({'obj': item, 'site': current_site})).decode('utf-8'),111 description = description_tmp.render(Context({'obj': item, 'site': current_site})).decode('utf-8'), 108 112 unique_id = link, 109 113 enclosure = enc, django/trunk/docs/syndication_feeds.txt
r3143 r3214 135 135 If you don't create a template for either the title or description, the 136 136 framework will use the template ``"{{ obj }}"`` by default -- that is, 137 the normal string representation of the object. 137 the normal string representation of the object. You can also change the 138 names of these two templates by specifying ``title_template`` and 139 ``description_template`` as attributes of your ``Feed`` class. 138 140 * To specify the contents of ``<link>``, you have two options. For each 139 141 item in ``items()``, Django first tries executing a … … 343 345 feed_type = feedgenerator.Rss201rev2Feed 344 346 347 # TEMPLATE NAMES -- Optional. These should be strings representing 348 # names of Django templates that the system should use in rendering the 349 # title and description of your feed items. Both are optional. 350 # If you don't specify one, or either, Django will use the template 351 # 'feeds/SLUG_title.html' and 'feeds/SLUG_description.html', where SLUG 352 # is the slug you specify in the URL. 353 354 title_template = None 355 description_template = None 356 345 357 # TITLE -- One of the following three is required. The framework looks 346 358 # for them in this order.
