【发布时间】:2018-04-25 08:02:17
【问题描述】:
使用的本地主机是 macOS 10.13 python 3.6 django 2.0.2
windowServer2012R2 使用 django 2.0.2、python 3.4、iis、fastCGI
如果我运行 localhost,我有这个屏幕截图:
并且把数据和post返回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'
'}')
我认为是编码问题,但我无法解决。
本地主机
print(request.body)
结果
`b'{\n "UserEmail": "",\n "UserPassword": "",\n "UserSex": 1,\n "UserAge": 1,\n "DeviceId": "",\n "PushKey": "",\n "OS": 1,\n "OSVersion": ""\n}'`
窗口服务器
`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
【问题讨论】: