override - django rest framework - adding to views.obtain_auth_token -


i have implemented token authentication django rest framework , can post username , password /api-token-auth/ , token.

url(r'^api-token-auth/', token_views.obtain_auth_token) 

in addition token, want user object related returned token.

how can override/add view , return actual user object?

you can find relevant view here:

https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/authtoken/views.py#l21

assuming you've created sort of user serializer already, can take user instance there , shove userserializer. add response, below.

...  user_serializer = userserializer(user) return response({'token': token.key, 'user': user_serializer.data}) 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -