# -*- coding: utf-8 -*-
+import feedparser
+import datetime
+
from django import template
from django.template import Node, Variable
from django.utils.encoding import smart_str
@register.inclusion_tag('catalogue/latest_blog_posts.html')
-def latest_blog_posts(feed_url, posts_to_show=5):
- import feedparser
- import datetime
-
+def latest_blog_posts(feed_url, posts_to_show=5):
try:
- feed = feedparser.parse(feed_url)
+ feed = feedparser.parse(str(feed_url))
posts = []
for i in range(posts_to_show):
pub_date = feed['entries'][i].updated_parsed
<div id="latest-blog-posts">
<h2>Aktualności</h2>
{% cache 1800 latest-blog-posts %}
- {% latest_blog_posts "http://www.nowoczesnapolska.org.pl/feed/?s=Wolne%20Lektury" %}
+ {% latest_blog_posts "http://www.nowoczesnapolska.org.pl/tematy/wolne-lektury/feed/" %}
{% endcache %}
<p class="see-more"><a href="http://www.nowoczesnapolska.org.pl/">Zobacz nasz blog ⇒</a></p>
</div>