I'm fairly new to Django and Python. I'm trying to build small RSS reader using feedparser. I'm getting this error and I can't seem to find any solutions anywhere
{'feed': {}, 'bozo': 1, 'bozo_exception': TypeError("'Feed' does not have the buffer interface",), 'entries': []}
Here are files which are involved (simplified version to ilustrate the problem)
## models
class Feed(models.Model):
name = models.CharField(max_length=100)
url = models.CharField(max_length=100)
category = models.ForeignKey(Category)
user = models.ManyToManyField(User)
def __unicode__(self):
return self.url
## views
def feed5(request):
source = Feed.objects.get(id=1)
rss = feedparser.parse(source)
context = {
'rss': rss,
}
return render(request, 'feedreader/feed5.html', context)
## feed5.html
{% block content %}
{{ rss }}
<p><a href ="{{ rss.feed.link }}">{{ rss.feed.title }}</a></p>
<ul>
{% for r in rss.entries|slice:":10" %}
<li> <a class="title" href="{{ r.link }}">{{ r.title }}</a> <br />{{ r.description }}</li>
{% endfor %}
</ul>
{% endblock %}
When I try to manually enter rss feed here
## views
def feed5(request):
source = Feed.objects.get(id=1)
**rss = feedparser.parse('http://rss.gazeta.pl/pub/rss/wiadomosci.htm')**
context = {
'rss': rss,
}
return render(request, 'feedreader/feed5.html', context)
It works fine, but when I pull it from DB, it doesn't work.
I went over this http://pythonhosted.org/feedparser/character-encoding.html and this feedparser fails during script run, but can't reproduce in interactive python console
but I can't figure it out. Would any of be able to help ?
thanks sikor
You should provide source.url not source to the feedparser