Skip to content

Commit

Permalink
Use firstname/last name only if the user has them
Browse files Browse the repository at this point in the history
  • Loading branch information
iMerica committed May 11, 2021
1 parent e11bb64 commit 5d5f923
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dj_rest_auth/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ class Meta:
extra_fields.append(UserModel.USERNAME_FIELD)
if hasattr(UserModel, "EMAIL_FIELD"):
extra_fields.append(UserModel.EMAIL_FIELD)

if hasattr(UserModel, "first_name"):
extra_fields.append('first_name')
if hasattr(UserModel, "last_name"):
extra_fields.append('last_name')
model = UserModel
fields = ('pk', *extra_fields, 'first_name', 'last_name')
fields = ('pk', *extra_fields)
read_only_fields = ('email',)


Expand Down

0 comments on commit 5d5f923

Please sign in to comment.