django给出错误__init __()需要3个参数(给定1个)

时间:2021-03-05 23:17:27

error is here: /data/http/cobalt/cards/urls.py in

错误在这里:/data/http/cobalt/cards/urls.py in

106:    (r'^latest/feed', LatestNews()) ...

this part of urls.py which throw an error

这部分urls.py会抛出错误

from django.conf.urls import patterns, url, include
from myproject.feeds import LatestNews

urlpatterns += patterns('',
    # ...
    (r'^latest/feed/$', LatestNews()),
    # ...

)

Actually I have copied all code from https://docs.djangoproject.com/en/1.1/ref/contrib/syndication/

实际上我已经复制了https://docs.djangoproject.com/en/1.1/ref/contrib/syndication/中的所有代码

but url they provide has mistake which i am not able to locate

但他们提供的网址有错误,我无法找到

3 个解决方案

#1


1  

In LatestNews, you are probably using

在LatestNews中,您可能正在使用

from django.contrib.syndication.feeds import Feed

instead of

from django.contrib.syndication.views import Feed 

#2


0  

The error must be with LatestNews. You are passing no arguments, meaning that it will receive one (the object itself). LatestNews is the only object being constructed on that line (the URL is a simple tuple, which has no fixed number of arguments).

错误必须与LatestNews一起。你没有传递任何参数,这意味着它会收到一个(对象本身)。 LatestNews是唯一在该行上构造的对象(URL是一个简单的元组,没有固定数量的参数)。

Check the LatestNews class - its __init__() method no doubt takes three arguments.

检查LatestNews类 - 它的__init __()方法无疑需要三个参数。

#3


0  

As you can see here and here these feed classes aren't meant as views. They are meant to be passed to the view django.contrib.syndication.views.feed as an argument.

正如您在此处所看到的,这些Feed类不是视图。它们应该作为参数传递给视图django.contrib.syndication.views.feed。

#1


1  

In LatestNews, you are probably using

在LatestNews中,您可能正在使用

from django.contrib.syndication.feeds import Feed

instead of

from django.contrib.syndication.views import Feed 

#2


0  

The error must be with LatestNews. You are passing no arguments, meaning that it will receive one (the object itself). LatestNews is the only object being constructed on that line (the URL is a simple tuple, which has no fixed number of arguments).

错误必须与LatestNews一起。你没有传递任何参数,这意味着它会收到一个(对象本身)。 LatestNews是唯一在该行上构造的对象(URL是一个简单的元组,没有固定数量的参数)。

Check the LatestNews class - its __init__() method no doubt takes three arguments.

检查LatestNews类 - 它的__init __()方法无疑需要三个参数。

#3


0  

As you can see here and here these feed classes aren't meant as views. They are meant to be passed to the view django.contrib.syndication.views.feed as an argument.

正如您在此处所看到的,这些Feed类不是视图。它们应该作为参数传递给视图django.contrib.syndication.views.feed。