I am a bit confused why I am getting this error. I do not know where it's getting this extra argument.
我有点搞不懂为什么会有这样的错误。我不知道这个额外的论点在哪里。
Environment:
Request Method: GET
Request URL: http://0.0.0.0:5000/
Django Version: 1.6.4
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'nirla.apps.blog')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/Users/nir/nirla/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
Exception Type: TypeError at /
Exception Value: __init__() takes exactly 1 argument (2 given)
Since this is a brand new project, I am a bit lost. I thought it could be that I pointed my urls at the same place twice (once in my main url conf and once in the app itself), but that didn't seem to fix it once I removed one.
因为这是一个全新的项目,我有点迷茫。我想可能是我将url指向了同一个地方两次(一次是在我的主url conf中,一次是在应用程序本身中),但这似乎并没有修复它,一旦我删除了一个。
For reference, here is the view that I am running:
作为参考,以下是我正在运行的视图:
class home(View):
template_name = "blog/home.html"
def get(self, request, *args, **kwargs):
return render(request, self.template_name)
Here is the main urls.py:
这是主要的袋子。
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
from nirla.apps.blog.views import home
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^$', home, name='home'),
)
As you can see, I have just started this project and everything is pretty bare. I can provide more info, but the project is bare.
正如你所看到的,我刚刚开始这个项目,所有的一切都非常的光秃秃。我可以提供更多的信息,但项目是赤裸裸的。
Thanks for helping a noobie.
谢谢你的帮助。
1 个解决方案
#1
24
Home is a class-based view. For those, you need to use the as_view
method in your URL pattern:
Home是基于类的视图。对于这些,您需要在URL模式中使用as_view方法:
url(r'^$', home.as_view(), name='home'),
See the documentation.
见文档。
#1
24
Home is a class-based view. For those, you need to use the as_view
method in your URL pattern:
Home是基于类的视图。对于这些,您需要在URL模式中使用as_view方法:
url(r'^$', home.as_view(), name='home'),
See the documentation.
见文档。