Import allauth.socialaccount only when declared in INSTALLED_APPS

Don't silently ignore ImportError
This commit is contained in:
Mario Rodas 2016-03-02 14:33:27 -05:00
parent e3fc4e64e9
commit 86a487fe21
2 changed files with 4 additions and 10 deletions

View File

@ -15,12 +15,8 @@ from rest_framework import serializers
from requests.exceptions import HTTPError
# Import is needed only if we are using social login, in which
# case the allauth.socialaccount will be declared
if 'allauth.socialaccount' in settings.INSTALLED_APPS:
try:
from allauth.socialaccount.helpers import complete_social_login
except ImportError:
pass
class SocialLoginSerializer(serializers.Serializer):

View File

@ -1,14 +1,12 @@
from django.conf import settings
from django.http import HttpRequest
from rest_framework import serializers
from requests.exceptions import HTTPError
# Import is needed only if we are using social login, in which
# case the allauth.socialaccount will be declared
try:
if 'allauth.socialaccount' in settings.INSTALLED_APPS:
from allauth.socialaccount.helpers import complete_social_login
except ImportError:
pass
from allauth.socialaccount.models import SocialToken
from allauth.socialaccount.models import SocialToken
class TwitterLoginSerializer(serializers.Serializer):