I'm trying to lowercase a username in a login request before passing it to the login view provided by django-rest-framework-jwt. This code:
@api_view(['POST'])
def login(request):
return obtain_jwt_token(request)
Works fine, though of course it effectively does nothing. Strangely, adding
print request.data
before the function returns causes a 400 error to be produced, with the message:
{"detail":"JSON parse error - No JSON object could be decoded"}
Why does simply reading the request object break the JSON parsing in this way?
Versions:
Django==1.9.1
djangorestframework==3.3.2
djangorestframework-jwt==1.7.2
As an added note: the print statement works fine, but breaks the JSON parsing. Printing request.POST
has the same effect, however, printing request.body
does not cause the error.
Because of reasons "Content-Type: application/json" header breaks DRF-JWT. Just remove it.
Seen here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.