mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-11-22 09:06:40 +03:00
custom serializers settings
This commit is contained in:
parent
489bac6e1f
commit
2b5942c4ac
41
rest_auth/app_settings.py
Normal file
41
rest_auth/app_settings.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from django.conf import settings
|
||||
|
||||
from rest_auth.serializers import (
|
||||
TokenSerializer as DefaultTokenSerializer,
|
||||
UserDetailsSerializer as DefaultUserDetailsSerializer,
|
||||
LoginSerializer as DefaultLoginSerializer,
|
||||
PasswordResetSerializer as DefaultPasswordResetSerializer,
|
||||
PasswordResetConfirmSerializer as DefaultPasswordResetConfirmSerializer,
|
||||
PasswordChangeSerializer as DefaultPasswordChangeSerializer)
|
||||
from allauth.utils import import_callable
|
||||
|
||||
|
||||
serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {})
|
||||
|
||||
TokenSerializer = import_callable(
|
||||
serializers.get('TOKEN_SERIALIZER', DefaultTokenSerializer))
|
||||
|
||||
UserDetailsSerializer = import_callable(
|
||||
serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer)
|
||||
)
|
||||
|
||||
LoginSerializer = import_callable(
|
||||
serializers.get('LOGIN_SERIALIZER', DefaultLoginSerializer)
|
||||
)
|
||||
|
||||
PasswordResetSerializer = import_callable(
|
||||
serializers.get('PASSWORD_RESET_SERIALIZER',
|
||||
DefaultPasswordResetSerializer)
|
||||
)
|
||||
|
||||
PasswordResetConfirmSerializer = import_callable(
|
||||
serializers.get('PASSWORD_RESET_CONFIRM_SERIALIZER',
|
||||
DefaultPasswordResetConfirmSerializer)
|
||||
)
|
||||
|
||||
PasswordChangeSerializer = import_callable(
|
||||
serializers.get('PASSWORD_RESET_SERIALIZER',
|
||||
DefaultPasswordChangeSerializer)
|
||||
)
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ from rest_framework.authentication import SessionAuthentication, \
|
|||
from rest_framework.authtoken.models import Token
|
||||
from rest_framework.generics import RetrieveUpdateAPIView
|
||||
|
||||
from rest_auth.serializers import (TokenSerializer, UserDetailsSerializer,
|
||||
from app_settings import (TokenSerializer, UserDetailsSerializer,
|
||||
LoginSerializer, PasswordResetSerializer, PasswordResetConfirmSerializer,
|
||||
PasswordChangeSerializer)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user