Skip to content

Commit 86a487f

Browse files
committed
Import allauth.socialaccount only when declared in INSTALLED_APPS
Don't silently ignore ImportError
1 parent e3fc4e6 commit 86a487f

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

rest_auth/registration/serializers.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
from requests.exceptions import HTTPError
1616
# Import is needed only if we are using social login, in which
1717
# case the allauth.socialaccount will be declared
18-
1918
if 'allauth.socialaccount' in settings.INSTALLED_APPS:
20-
try:
21-
from allauth.socialaccount.helpers import complete_social_login
22-
except ImportError:
23-
pass
19+
from allauth.socialaccount.helpers import complete_social_login
2420

2521

2622
class SocialLoginSerializer(serializers.Serializer):

rest_auth/social_serializers.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1+
from django.conf import settings
12
from django.http import HttpRequest
23
from rest_framework import serializers
34
from requests.exceptions import HTTPError
45
# Import is needed only if we are using social login, in which
56
# case the allauth.socialaccount will be declared
6-
try:
7+
if 'allauth.socialaccount' in settings.INSTALLED_APPS:
78
from allauth.socialaccount.helpers import complete_social_login
8-
except ImportError:
9-
pass
10-
11-
from allauth.socialaccount.models import SocialToken
9+
from allauth.socialaccount.models import SocialToken
1210

1311

1412
class TwitterLoginSerializer(serializers.Serializer):

0 commit comments

Comments
 (0)