Django 简单联合示例给出:ImportError,无法导入名称 Feed

发布于 2024-08-28 12:47:30 字数 782 浏览 12 评论 0原文

我正在尝试设置 简单的联合示例 来自 Django 文档,在一个工作项目中。但我收到了 ImportError,即使我确信我已经准确复制了该示例。

这是我在 feeds.py 中的内容:

from django.contrib.syndication.views import Feed 
class LatestEntriesFeed(Feed):
    # etc

这是我在 urls.py 中的内容:

from election.feeds import LatestEntriesFeed
#... further down, at the appropriate line...
    # RSS feed
    (r'^feed/$', LatestEntriesFeed()),

但 Django 说它无法从 django.contrib.syndicate.views 导入 Feed 类:

ImportError at /feed/
cannot import name Feed
....feeds.py in <module>
from django.contrib.syndication.views import Feed  

有什么想法吗?我很困惑!

I'm trying to set up the simple syndication example from the Django docs, in a working project. But I'm getting an ImportError, even though I'm sure I've copied the example exactly.

Here's what I have in feeds.py:

from django.contrib.syndication.views import Feed 
class LatestEntriesFeed(Feed):
    # etc

And here's what I have in urls.py:

from election.feeds import LatestEntriesFeed
#... further down, at the appropriate line...
    # RSS feed
    (r'^feed/

But Django says it can't import the Feed class from django.contrib.syndication.views:

ImportError at /feed/
cannot import name Feed
....feeds.py in <module>
from django.contrib.syndication.views import Feed  

Any ideas? I'm baffled!

, LatestEntriesFeed()),

But Django says it can't import the Feed class from django.contrib.syndication.views:

Any ideas? I'm baffled!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放手` 2024-09-04 12:47:30

该文档适用于开发版本。为了准备 1.2,提要发生了很大变化。如果您使用的是 1.1,则应使用1.1 文档

That documentation is for the development version. Feeds have changed quite a lot in preparation for 1.2. If you're using 1.1, you should use the 1.1 docs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文