5

I've updated my Django version to the latest nightly, and I'm getting the following error in the admin;

Could not import django.contrib.syndication.views.feed.  
View does not exist in module django.contrib.syndication.views.

I had this error in several views too because, indeed, django.contrib.syndication.views.feed was deprecated and has been removed.
I only had to add a

from django.contrib.syndication.views import Feed

with

from django.contrib.syndication.feeds import Feed

Problem is that I can't find any references to django.contrib.syndication.views.feed anywhere, not even in the Django source, so I don't understand where the error is coming from and how to solve it.

The direct source of the error is

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py in get_callable, line 100

but I can't find anything there either.

Hoping someone can help!

1
  • I have discovered that the source of the problem is - al least partially - in using {% comment_form_target %} in my template. There's probably some dynamic guessing going on as to where the form should point, importing feed along the way. Jul 13, 2011 at 23:02

2 Answers 2

11

user643511 suggested that the error might be in my own code, not Django. However she didn't point out the real problem (which I understand since I didn't provide the right information). Only after days of digging I found that I had

url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),

in urls.py. And instead, I had to use

url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.Feed', {'feed_dict': feeds}),

Mind the capital F in views.Feed.

So if anyone passes by with similar trouble, check urls.py.

7

Maybe you have something wrong in your code, I make some test and the high-level feed-generating framework works fine. You only have to use the Feed class

django.contrib.syndication.views.Feed

This is a simple example: In your models


# -*- coding: utf8 -*-
from django.utils.translation import ugettext as _
from django.contrib.syndication.views import Feed
from django.db import models

class Concept(models.Model):
    concept = models.IntegerField(unique=True, primary_key=True, verbose_name=_('Concepto'))
    description = models.CharField(max_length=255, verbose_name=_('Descripcion'))

    def __unicode__(self):
        return "%s" % ( self.description or self.concept )

    class Meta:
        verbose_name = _('Concepto')
        verbose_name_plural = _('Conceptos')
        ordering = ['concept']

class LatestEntriesFeed(Feed):
    title = "My site news"
    link = "/sitenews/"
    description = "Updates on changes and additions."

    def items(self):
        return Concept.objects.all()

    def item_code(self, item):
        return item.code

    def item_description(self, item):
        return item.description

and in your url:


from models import LatestEntriesFeed

urlpatterns = patterns('',
    (r'^latest/feed/$', LatestEntriesFeed()),    
)

result:

My site newshttp://example.com/sitenews/Updates on changes and additions.es-esTue, 12 Jul 2011 08:18:49 -0000

I hope that help.

2
  • Thanks for the response, but no that doesn't help at all. As I was saying, the problem I'm having is that I don't know where the error is occurring really, since I can't find any file on my entire system that imports feed from the wrong namespace. Looking at your source it is clear that you are not running a late version of Django, otherwise you're import would give problems to. from django.contrib.syndication.views import Feed is deprecated. Jul 13, 2011 at 22:20
  • 1
    I'm sorry, it turns out you were somewhat right after all; the error was in my own code. I had a reference to django.contrib.syndication.views.feed in my url, instead of django.contrib.syndication.views.Feed (God is in the details). I'll submit my own answer for those who pass by in the future. Jul 14, 2011 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.