Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#2158 closed enhancement (fixed)

[patch] Syndication framework doesn't allow custom template paths.

Reported by: James Wheare Owned by: adrian
Component: Contrib apps Version: master
Severity: normal Keywords: syndication, feeds, templates, urls
Cc: django@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Let me illustrate this with an example.

I have two sorts of feeds in my app:

/authors/feed/ # simple feed of all authors
/authors/authorname/feed/ # complex per-author feed

Defined by the following URLconf

feeds = {
	'authors': AuthorsFeed,
}
author_feed = {
	'authors': AuthorFeed,
}
(r'^(?P<url>authors/[-\w]+)/feed/$', 'feed', {'feed_dict': author_feed}),
(r'^(?P<url>authors)/feed/$', 'feed', {'feed_dict': feeds}),

The problem is that both urls share the same slug "authors" which determines the feed model to use and—more critically—the template paths (authors_description, authors_title)

I managed to work around the model issue by specifying two different feed_dicts but I can't see a way to specify different templates for each feed without patching django.contrib.syndication.views.

Attachments (1)

syndication.diff (2.2 KB) - added by James Wheare 9 years ago.
Added ability to specify title and description templates

Download all attachments as: .zip

Change History (10)

comment:1 Changed 9 years ago by anonymous

  • Cc django@… added

Changed 9 years ago by James Wheare

Added ability to specify title and description templates

comment:2 Changed 9 years ago by James Wheare

  • Severity changed from major to normal
  • Summary changed from Syndication framework doesn't allow custom template paths for description and title per feed url. to [patch] Syndication framework doesn't allow custom template paths.

comment:3 Changed 9 years ago by James Wheare

I'm sure this patch is a really hackish way of doing this and the variable names are awful but at least it works.

comment:4 Changed 9 years ago by anonymous

Ack! Ignore "comments_extras.diff". I accidentally attached that to the wrong ticket. My apologies.

comment:5 Changed 9 years ago by adrian

  • Status changed from new to assigned

Patch appears to use 8 spaces instead of 4

comment:6 Changed 9 years ago by James Wheare <django@…>

Yeah, can't figure out how to reduce spaces-per-tab in TextMate.

comment:7 Changed 9 years ago by James Wheare <django@…>

Actually, it *is* using 4 spaces, trac seems to be screwing the formatting it up, check the raw format. (And yes, I figured out the textmate issue, stupid me)

comment:8 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [3214]) Fixed #2158 -- Added title_template and description_template hooks to Feed class in syndication framework.

comment:9 Changed 9 years ago by James Wheare <django@…>

Ah yes much cleaner. Thanks :)

Note: See TracTickets for help on using tickets.
Back to Top