/ admin /'set'对象的TypeError不可逆,反转的argument()必须是序列

时间:2017-04-09 09:01:11

标签: python django web-applications django-admin typeerror

我的应用程序运行正常,但是当我尝试管理网址时,发生了此错误。我可以访问网站的每个页面,但管理页面除外。 我的项目是迷你 mini.urls.py

from django.conf.urls import url,include
from django.contrib import admin

urlpatterns = [
     url(r'^admin/', admin.site.urls),
     url(r'^', include('main.urls')),
     url(r'^', include('signup.urls',namespace='signup')),
]

main.urls.py

 from django.conf.urls import url,include
 from . import views

 urlpatterns = [
      url(r'^$', views.index,name='index'),
 ]

signup.urls.py

 from django.conf.urls import url,include
 from . import views

 urlpatterns = {
    url(r'^signup/$', views.register, name='register'),
    url(r'^login/$', views.login_user, name='login'),
    url(r'^userpage/$', views.user_page, name='userpage'),
    url(r'^upload/$', views.upload_file, name='upload'),
    url(r'^logout/$', views.logout_user, name='logout'),
    url(r'^(?P<uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]
                                {12})/$', views.doc_detail, name='detail'),
    url(r'^(?P<uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]
                                {12})/decrypt/$', views.doc_decrypt, 
                                            name='docdecrypt'),
     }

我在/ admin /

遇到的错误
     TypeError at /admin/
     'set' object is not reversible
     Request Method:    GET
     Request URL:   http://127.0.0.1:8000/admin/
     Django Version:    1.10.5
     Exception Type:    TypeError
     Exception Value:   
     'set' object is not reversible
     Exception Location:    
     C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-
     packages\django\urls\resolvers.py in _populate, line 196
     Python Executable: 
     C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe
     Python Version:    3.6.0
     Python Path:   
     ['C:\\Users\\user\\Desktop\\django projects\\mini',
     'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-
     32\\python36.zip',
     'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs',
     'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-32\\lib',
     'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-32',
     'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36-
     32\\lib\\site-packages']

我尝试在另一台电脑上运行我的webapp,因此我遇到了以下错误:

     TypeError at /admin/
     argument to reversed() must be a sequence
     Request Method:    GET
     Request URL:   http://127.0.0.1:8000/admin/
     Django Version:    1.10.5
     Exception Type:    TypeError
     Exception Value:   
     argument to reversed() must be a sequence
     Exception Location:    C:\Python27\lib\site-
     packages\django\urls\resolvers.py in _populate, line 196
     Python Executable: C:\Python27\python.exe
     Python Version:    2.7.12
     Python Path:   
     ['C:\\Users\\Admin\\Desktop\\mini',
     'C:\\Python27\\lib\\site-packages\\steganography-0.1.1-py2.7.egg',
     'C:\\Python27\\lib\\site-packages\\pillow-4.0.0-py2.7-win32.egg',
     'C:\\Python27\\lib\\site-packages\\olefile-0.44-py2.7.egg',
     'C:\\WINDOWS\\SYSTEM32\\python27.zip',
     'C:\\Python27\\DLLs',
     'C:\\Python27\\lib',
     'C:\\Python27\\lib\\plat-win',
     'C:\\Python27\\lib\\lib-tk',
     'C:\\Python27',
     'C:\\Python27\\lib\\site-packages']

6 个答案:

答案 0 :(得分:4)

在main.urls.py中将{}更改为[]

答案 1 :(得分:2)

在signup.urls.py中将括号从这些{}更改为[]这些将起作用

答案 2 :(得分:0)

我在这里找到了解决方案,并为我工作

urlpatterns = [
     url(r'^admin/', admin.site.urls),
     url(r'^', include('main.urls')),
     url(r'^', include('signup.urls',namespace='signup')),
]

删除&#34;,&#34;从urlpatterns数组的最后一行

urlpatterns = [
     url(r'^admin/', admin.site.urls),
     url(r'^', include('main.urls')),
     url(r'^', include('signup.urls',namespace='signup'))
]

http://stackoverflaw.com/question/set-project-is-not-revertable-in-_populate-line-416/

答案 3 :(得分:0)

检查该文件中的urls.py,检查urlpatterns = []中的方括号 因为它在Curly括号中会显示'set'对象是不可逆的,并且arguments()错误...请尝试执行此操作...

答案 4 :(得分:0)

我在项目中遇到了同样的问题,将大括号{}更改为方括号[],问题已解决。

答案 5 :(得分:0)

在主项目 urls.py 中将 urlpatterns 元组从 {} 更改为 []

PROJECT_NAME/urls.py

只需检查并在每个该死的 urls.py 处将 curl 更改为方形

就是这样......它会起作用!!