Allow using custom UserDetailsSerializer with JWTSerializer

This commit is contained in:
Maxim Kukhtenkov 2016-10-31 20:45:33 -07:00
parent 70d03e3e9b
commit a907efc06b

View File

@ -135,7 +135,16 @@ class JWTSerializer(serializers.Serializer):
Serializer for JWT authentication. Serializer for JWT authentication.
""" """
token = serializers.CharField() token = serializers.CharField()
user = UserDetailsSerializer()
def __init__(self, *args, **kwargs):
"""
Need to add `user` field dynamically, to allow using
custom UserDetailsSerializer
"""
from app_settings import UserDetailsSerializer
super(JWTSerializer, self).__init__(*args, **kwargs)
self.fields['user'] = UserDetailsSerializer()
class PasswordResetSerializer(serializers.Serializer): class PasswordResetSerializer(serializers.Serializer):