I am trying to return the users id with the token after the user registers but only the token is being returned
I am using dj-rest-auth and docs say I can serialize extra fields with the RegisterSerializer
My serializer:
from dj_rest_auth.registration.serializers import RegisterSerializer
class CustomRegistrationSerializer(RegisterSerializer):
user_id = serializers.SerializerMethodField('get_user_id')
def get_user_id(self, obj):
o = obj['username']
user_id = User.objects.get(username=o).id
print(user_id)
return Response(user_id)
My settings:
REST_AUTH_REGISTER_SERIALIZERS = {
'REGISTER_SERIALIZER': 'users.serializers.CustomRegistrationSerializer'
}
I am able to print the id in my console, but in the api response it's only returning the token and not the id
Appreciate any help! Don't know what I am doing wrong.