Django DRY Feeds
Posted
by Mandx
on Stack Overflow
See other posts from Stack Overflow
or by Mandx
Published on 2010-05-06T21:29:34Z
Indexed on
2010/05/08
2:38 UTC
Read the original article
Hit count: 467
I'm using the Django Feeds Framework and it's really nice, very intuitive and easy to use. But, I think there is a problem when creating links to feeds in HTML.
For example:
<link rel="alternate" type="application/rss+xml" title="{{ feed_title }}" href="{{ url_of_feed }}" />
Link's HREF
attribute can be easily found out, just use reverse()
But, what about the TITLE
attribute? Where the template engine should look for this? Even more, what if the feed is build up dinamically and the title depends on parameters (like this)?
I can't come up with a solution that "seems" DRY to me... All that I can come up with is using context processors o template tags, but it gets messy when the context procesor/template tag has to find parameters to construct the Feed class, and writing this I realize I don't even know how to create a Feed instance myself within the view.
If I put all this logic in the view, it would not be just one view. Also, the value for TITLE
would be in the view AND in the feed.
© Stack Overflow or respective owner