以下为报错信息:
Internal Server Error: /api/xadmin/v1/sys/menu
File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
raise exc
File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\rest_framework\views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "C:\Users\xuyic\Downloads\django-antd-tyadmin-master\django-antd-tyadmin-master\demos\tyadmin_demo_init\tyadmin_api\views.py", line 72, in get
content = demjson.decode(content)
File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\demjson.py", line 2039, in decode
j = JSON( strict=strict )
File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\demjson.py", line 911, in init
for c in range(0,256)]
File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\demjson.py", line 911, in
for c in range(0,256)]AttributeError: 'dict' object has no attribute 'has_key'
项目中用到了demjson,demsjon包在python的setuptools 58.0版本以后就不再被python3支持 目前demjson项目特别划分出了一个项目分支demjson3:
https://pypi.org/project/demjson3/
具体参见issue: https://github.com/dmeranda/demjson/issues/40
改法有两个:
以下为报错信息: Internal Server Error: /api/xadmin/v1/sys/menu File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception raise exc File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\rest_framework\views.py", line 506, in dispatch response = handler(request, *args, **kwargs) File "C:\Users\xuyic\Downloads\django-antd-tyadmin-master\django-antd-tyadmin-master\demos\tyadmin_demo_init\tyadmin_api\views.py", line 72, in get content = demjson.decode(content) File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\demjson.py", line 2039, in decode j = JSON( strict=strict ) File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\demjson.py", line 911, in init for c in range(0,256)] File "C:\Users\xuyic\anaconda3\envs\py36\lib\site-packages\demjson.py", line 911, in
for c in range(0,256)]AttributeError: 'dict' object has no attribute 'has_key'
报错的主要原因是Python3以后删除了has_key()方法,可以把has_key换成in方法解决这个报错,但是也不推荐,因为demjson项目中并不是只有这一点不兼容python3,还有挺多地方,改起来非常麻烦。
项目环境: python==3.6 django==3.3
望采纳,额外补充一句,感谢作者大大的好项目!救命了!