django中的小坑
程序员文章站
2022-03-25 11:14:05
...
argument to reversed() must be a sequence
Request Method: GET
Request URL: http://127.0.0.1:8000/user/address/
Django Version: 1.8.7
Exception Type: TypeError
Exception Value:
argument to reversed() must be a sequence
Exception Location: /home/python/.virtualenvs/django_py2/local/lib/python2.7/site-packages/django/core/urlresolvers.py in _populate, line 284
Python Executable: /home/python/.virtualenvs/django_py2/bin/python
Python Version: 2.7.12
Python Path:
['/home/python/Desktop/ws/syttsx',
'/home/python/Desktop/ws/syttsx',
'/home/python/.virtualenvs/django_py2/lib/python2.7',
'/home/python/.virtualenvs/django_py2/lib/python2.7/plat-x86_64-linux-gnu',
'/home/python/.virtualenvs/django_py2/lib/python2.7/lib-tk',
'/home/python/.virtualenvs/django_py2/lib/python2.7/lib-old',
'/home/python/.virtualenvs/django_py2/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/python/.virtualenvs/django_py2/local/lib/python2.7/site-packages']
Server time: 星期四, 19 十月 2017 19:00:47 +0800
错误信息如上所示,是因为应用下的urls.py里面的urlpatterns,这个变量后面跟的是一个列表而不是字典,把外边的花括号改成列表即可…
错误配置
urlpatterns = {
url(r'^$', views.xxx),
}
正确的配置
urlpatterns = [
url(r'^$', views.xxx),
]