diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/syndication/feeds.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py index 3deefc5866..e648c6c746 100644 --- a/django/contrib/syndication/feeds.py +++ b/django/contrib/syndication/feeds.py @@ -16,10 +16,14 @@ class Feed(object): item_pubdate = None item_enclosure_url = None feed_type = feedgenerator.DefaultFeed + title_template = None + description_template = None def __init__(self, slug, feed_url): self.slug = slug self.feed_url = feed_url + self.title_template_name = self.title_template or ('feeds/%s_title.html' % slug) + self.description_template_name = self.description_template or ('feeds/%s_description.html' % slug) def item_link(self, item): try: @@ -77,13 +81,13 @@ class Feed(object): ) try: - title_template = loader.get_template('feeds/%s_title.html' % self.slug) + title_tmp = loader.get_template(self.title_template_name) except TemplateDoesNotExist: - title_template = Template('{{ obj }}') + title_tmp = Template('{{ obj }}') try: - description_template = loader.get_template('feeds/%s_description.html' % self.slug) + description_tmp = loader.get_template(self.description_template_name) except TemplateDoesNotExist: - description_template = Template('{{ obj }}') + description_tmp = Template('{{ obj }}') for item in self.__get_dynamic_attr('items', obj): link = add_domain(current_site.domain, self.__get_dynamic_attr('item_link', item)) @@ -102,9 +106,9 @@ class Feed(object): else: author_email = author_link = None feed.add_item( - title = title_template.render(Context({'obj': item, 'site': current_site})).decode('utf-8'), + title = title_tmp.render(Context({'obj': item, 'site': current_site})).decode('utf-8'), link = link, - description = description_template.render(Context({'obj': item, 'site': current_site})).decode('utf-8'), + description = description_tmp.render(Context({'obj': item, 'site': current_site})).decode('utf-8'), unique_id = link, enclosure = enc, pubdate = self.__get_dynamic_attr('item_pubdate', item), |
