我正在构建一个djangojwtapi并完成登录/注销/注册路由。我正在尝试创建一个新的路由,该路由接受来自经过身份验证的用户的post请求中的json数据,并最终将其添加到用户的数据库中。你知道吗
我正在用Postman测试这个路由,发送头中的Authroization键以及json数据。在我的视图.py我可以成功地识别post请求并打印json数据,但是在任何地方都找不到授权头。如果我想打印出来请求.headers'它说“AttributeError:'WSGIRequest'对象没有属性'headers'”
你知道吗视图.py地址:
def HomePageView(请求):
if request.method=='POST':
print('its a post')
print('request: ' + str(request))
print('request.body: ' + str(request.body))
print('request.method: ' + str(request.method))
print('request.headers: ' + str(request.headers))
return StreamingHttpResponse('response')
目前没有回答
相关问题 更多 >
编程相关推荐