File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 6
6
from django .utils .translation import ugettext_lazy as _
7
7
from django .utils .encoding import force_text
8
8
9
- from .models import TokenModel
10
-
11
9
from rest_framework import serializers , exceptions
12
10
from rest_framework .exceptions import ValidationError
13
11
12
+ from .models import TokenModel
13
+ from .utils import import_callable
14
+
14
15
# Get the UserModel
15
16
UserModel = get_user_model ()
16
17
@@ -130,12 +131,20 @@ class Meta:
130
131
read_only_fields = ('email' , )
131
132
132
133
134
+ # Required to allow using custom USER_DETAILS_SERIALIZER in
135
+ # JWTSerializer. Defining it here to avoid circular imports
136
+ rest_auth_serializers = getattr (settings , 'REST_AUTH_SERIALIZERS' , {})
137
+ JWTUserDetailsSerializer = import_callable (
138
+ rest_auth_serializers .get ('USER_DETAILS_SERIALIZER' , UserDetailsSerializer )
139
+ )
140
+
141
+
133
142
class JWTSerializer (serializers .Serializer ):
134
143
"""
135
144
Serializer for JWT authentication.
136
145
"""
137
146
token = serializers .CharField ()
138
- user = UserDetailsSerializer ()
147
+ user = JWTUserDetailsSerializer ()
139
148
140
149
141
150
class PasswordResetSerializer (serializers .Serializer ):
You can’t perform that action at this time.
0 commit comments