Skip to content

Commit

Permalink
Added docstrings to serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
apragacz committed Feb 23, 2019
1 parent 40e302d commit 479fb58
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions rest_registration/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,35 @@ class MetaObj(object):


class DefaultLoginSerializer(serializers.Serializer):
"""
Default serializer used for user login. It will use
:ref:`user-login-fields-setting` setting to compare the login
to the user login fields defined by this setting.
"""
login = serializers.CharField()
password = serializers.CharField()

def get_authenticated_user(self):
"""
Return authenticated user if login and password match.
Return ``None`` otherwise.
"""
data = self.validated_data
return authenticate_by_login_and_password_or_none(
data['login'], data['password'])


class DefaultUserProfileSerializer(serializers.ModelSerializer):
"""
Default serializer used for user profile. It will use these:
* User fields
* :ref:`user-hidden-fields-setting` setting
* :ref:`user-public-fields-setting` setting
* :ref:`user-editable-fields-setting` setting
to automagically generate the required serializer fields.
"""

def __init__(self, *args, **kwargs):
user_class = get_user_model()
Expand Down

0 comments on commit 479fb58

Please sign in to comment.