使用的本地主机是macOS 10.13 python 3.6 django 2.0.2
WindowsServer2012R2使用django 2.0.2、python 3.4、iis、fastCGI
如果我运行localhost,我有以下截图:
并将数据和post return 200连接成功:
但是CSS在窗口服务器上不起作用。
此屏幕截图:
并将数据和后期制作:
异常JSON对象必须是str,而不是“bytes”
在里面
json.loads(request.body)
Django调试后期数据
_content_type
'application/json'
_content
('{\r\n'
' "UserEmail": "",\r\n'
' "UserPassword": "",\r\n'
' "UserSex": 1,\r\n'
' "UserAge": 1,\r\n'
' "DeviceId": "",\r\n'
' "PushKey": "",\r\n'
' "OS": 1,\r\n'
' "OSVersion": ""\r\n'
'}')
enter image description here
我认为这是一个编码问题,但我不能解决它。
本地服务器
print(request.body)
后果
`b'{\n "UserEmail": "",\n "UserPassword": "",\n "UserSex": 1,\n "UserAge": 1,\n "DeviceId": "",\n "PushKey": "",\n "OS": 1,\n "OSVersion": ""\n}'`
Windows服务器
`b'_content_type=application%2Fjson&_content=%7B%0D%0A++++%22UserEmail%22%3A+%22%22%2C%0D%0A++++%22UserPassword%22%3A+%22%22%2C%0D%0A++++%22UserSex%22%3A+1%2C%0D%0A++++%22UserAge%22%3A+1%2C%0D%0A++++%22DeviceId%22%3A+%22%22%2C%0D%0A++++%22PushKey%22%3A+%22%22%2C%0D%0A++++%22OS%22%3A+1%2C%0D%0A++++%22OSVersion%22%3A+%22%22%0D%0A%7D'`
我试过了
json.loads(request.body.decode("utf-8"))
此例外
enter image description here