Manish J
Manish J

Reputation: 736

django parse Response header X-Auth

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)

How to Parse Response Header in django.

Upvotes: 0

Views: 67

Answers (1)

pjoshi
pjoshi

Reputation: 338

You can always send headers in Response as an argument and pass the header object like this

header = { X-Auth: result.tokenHash }
return Response(result, status=status.HTTP_201_CREATED, headers=header)

Also you can get more information about the Django Response here.

Hope that solves your problem.

Upvotes: 1

Related Questions