我正在使用django创建一个todo应用程序,但在重定向到http://127.0.0.1:8000/admin/时我收到错误
'module'对象没有属性' getitem '
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version: 1.11.2
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'todolist.apps.TodolistConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'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']
Exception Type: TypeError at /admin/login/
Exception Value: 'module' object has no attribute '__getitem__'
我得到的追溯是:
File "/home/knight/.local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/home/knight/.local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/home/knight/.local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in login
393. return LoginView.as_view(**defaults)(request)
File "/home/knight/.local/lib/python2.7/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/knight/.local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/knight/.local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/knight/.local/lib/python2.7/site-packages/django/contrib/auth/views.py" in dispatch
90. return super(LoginView, self).dispatch(request, *args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/views/generic/edit.py" in get
174. return self.render_to_response(self.get_context_data())
File "/home/knight/.local/lib/python2.7/site-packages/django/contrib/auth/views.py" in get_context_data
121. context = super(LoginView, self).get_context_data(**kwargs)
File "/home/knight/.local/lib/python2.7/site-packages/django/views/generic/edit.py" in get_context_data
93. kwargs['form'] = self.get_form()
File "/home/knight/.local/lib/python2.7/site-packages/django/views/generic/edit.py" in get_form
45. return form_class(**self.get_form_kwargs())
File "/home/knight/.local/lib/python2.7/site-packages/django/contrib/auth/forms.py" in __init__
179. if self.fields['username'].label is None:
答案 0 :(得分:0)
完成了!刚刚更改了一些功能并将django 1.11.2更新为1.11.4,现在效果很好!