/ admin /'set'对象的TypeError不可逆

时间:2017-03-22 13:23:08

标签: django-admin typeerror

环境:

请求方法:GET请求网址:http://127.0.0.1:8000/admin/

Django版本:1.10.6 Python版本:3.6.0已安装的应用程序:['music.apps.MusicConfig','django.contrib.admin','django.contrib.auth','django.contrib.contenttypes' ,'django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles']已安装的中间件:['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']

回溯:

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ core \ handlers \ exception 。内部的.py“响应= get_response(请求)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ core \ handlers \ base .py“in _legacy_get_response 249. response = self._get_response(request)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ core \ handlers \ base .py“in _get_response 187. response = self.process_exception_by_middleware(e,request)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ core \ handlers \ base .py“in _get_response 185. response = wrapped_callback(request,* callback_args,** callback_kwargs)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ contrib \ admin \ sites .py“在包装器229.中返回self.admin_view(查看,可缓存)(* args,** kwargs)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ utils \ decorators.py “在_wrapped_view 149. response = view_func(request,* args,** kwargs)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ views \ decorators \ cache .py“在_wrapped_view_func 57. response = view_func(request,* args,** kwargs)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ contrib \ admin \ sites内部211.py“返回视图(请求,* args,** kwargs)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ views \ decorators \ cache .py“在_wrapped_view_func 57. response = view_func(request,* args,** kwargs)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ contrib \ admin \ sites索引468中的.py“app_list = self.get_app_list(request)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ contrib \ admin \ sites .py“在get_app_list 451. app_dict = self._build_app_dict(request)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ contrib \ admin \ sites .py“in _build_app_dict 418. model_dict ['admin_url'] = reverse('admin:%s_%s_changelist'%info,current_app = self.name)

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ urls \ base.py “反向60. app_list = resolver.app_dict [ns]

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ urls \ resolvers.py “在app_dict 256. self._populate()

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ urls \ resolvers.py “在_populate 209.中,名字来自pattern.reverse_dict:

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ urls \ resolvers.py “在reverse_dict 242中.self._populate()

文件“C:\ Users \ Dell Laptop \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ django-1.10.6-py3.6.egg \ django \ urls \ resolvers.py “在_populate 196.中为反转模式(self.url_patterns):

异常类型:TypeError at / admin / Exception值:'set'对象不可逆

3 个答案:

答案 0 :(得分:4)

在您的网址中

将{}括号更改为[]这些

答案 1 :(得分:1)

您必须在urlpatterns变量所在的urls.py中将{}更改为[]

答案 2 :(得分:0)

请在您的urls.py文件中将{}更改为[]。 例如urlpatterns = [path('',views.itemlist,name =“ itemlist”),]