custom serializers settings

This commit is contained in:
Mateusz Sikora 2014-10-08 13:19:34 +02:00
parent 489bac6e1f
commit 2b5942c4ac
2 changed files with 42 additions and 1 deletions

41
rest_auth/app_settings.py Normal file
View 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)
)

View File

@ -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)