Python的Django框架入门踩过的坑(七)

需要设置safe=False,  JsonResponse(data, safe=False)


类型错误

TypeError at /area/0/
In order to allow non-dict objects to be serialized set the safe parameter to False
Request Method: GET
Request URL: http://127.0.0.1:8000/area/0/
Django Version: 1.8.2
Exception Type: TypeError
Exception Value:
In order to allow non-dict objects to be serialized set the safe parameter to False
Exception Location: /home/python/.virtualenvs/h1/local/lib/python2.7/site-packages/django/http/response.py in __init__, line 532
Python Executable: /home/python/.virtualenvs/h1/bin/python
Python Version: 2.7.12
Python Path:
['/home/python/Desktop/django/test5',
 '/home/python/.virtualenvs/h1/lib/python2.7',
 '/home/python/.virtualenvs/h1/lib/python2.7/plat-x86_64-linux-gnu',
 '/home/python/.virtualenvs/h1/lib/python2.7/lib-tk',
 '/home/python/.virtualenvs/h1/lib/python2.7/lib-old',
 '/home/python/.virtualenvs/h1/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/h1/local/lib/python2.7/site-packages',
 '/home/python/.virtualenvs/h1/lib/python2.7/site-packages']
Server time: 星期日, 1 四月 2018 16:17:21 +0800

猜你喜欢

转载自blog.csdn.net/chenhua1125/article/details/80074400