cursor.execute("SELECT DISTINCT User.name,Person.id,Person.firstName,Person.lastName,User.tokenHash from User JOIN Person ON User.personId = Parkloco.Person.id WHERE User.name = '%s' AND User.enabled = 1 " % username)
fields = map(lambda x: x[0], cursor.description)
result = [dict(zip(fields, row)) for row in cursor.fetchall()]
Response['X-Auth'] = result.tokenHash
return Response(result,status=status.HTTP_201_CREATED)
如何在django中解析响应头。
答案 0 :(得分:1)
您始终可以将Response中的标头作为参数发送,并像这样传递标题对象
header = { X-Auth: result.tokenHash }
return Response(result, status=status.HTTP_201_CREATED, headers=header)
您还可以获得有关Django Response here的更多信息。
希望能解决你的问题。