views:

19

answers:

1

Hi guys, im doing something with feedparser: i have a templatetag for display "news" in my home page, but , how ill limit the feedparser result?

inclusion tag

from django.template import Template, Library
import feedparser
register = Library()

@register.inclusion_tag('rss_render.html')
def rss_render(object): #RSS URL "object"
    rss = feedparser.parse(object)       
    return {'rss': rss}

template

<ul>
{% for r in rss.entries %}
<li> <a href="{{ r.link }}" target="_blank" title="{{ r.title }}">{{ r.title }}</a></li>
{% endfor %}
</ul>
A: 

Take this Django snippet for example.

rebus