I am currently setting up a django backend for a React frontend app.
As part of of, I am using django-rest-auth and django-allauth for registration and authentication. I wanted to implement better token management through django-rest-knox.
I used the following code to start from and modify my existing app with rest-auth and allauth (which works):
https://gist.github.com/AndrewPix/cdd9276b1d5683459b965d5cc4517b26
My problem is the following:
When I POST my credentials to the url /rest-auth/login, in the backend a token gets created for the right user, with all the attributes (e.g. expiry date), but I don't get the token and user returned as part of the API call. Instead I receive the below error:
AttributeError at /rest-auth/login/
Got AttributeError when attempting to get a value for field token
on serializer KnoxSerializer
.
The serializer field might be named incorrectly and not match any attribute or key on the str
instance.
Original exception text was: 'str' object has no attribute 'token'.
Any help would be greatly appreciated. I think something is wrong with the KnoxSerializer but I can't figure out what?
Thanks!
AM