From 47b43a523521123890b1c5feec48ec92b3213083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Rossigneux?= Date: Sat, 31 Mar 2018 00:20:58 +0200 Subject: [PATCH] Fix UserWarning in SocialAccountListView and SocialAccountDisconnectView Django was raising "is not compatible with schema generation" user warning at startup --- rest_auth/registration/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rest_auth/registration/views.py b/rest_auth/registration/views.py index 0e0ab0d..f0c07e6 100644 --- a/rest_auth/registration/views.py +++ b/rest_auth/registration/views.py @@ -154,7 +154,10 @@ class SocialAccountListView(ListAPIView): permission_classes = (IsAuthenticated,) def get_queryset(self): - return SocialAccount.objects.filter(user=self.request.user) + if self.request: + return SocialAccount.objects.filter(user=self.request.user) + else: + return SocialAccount.objects.none() class SocialAccountDisconnectView(GenericAPIView): @@ -166,7 +169,10 @@ class SocialAccountDisconnectView(GenericAPIView): permission_classes = (IsAuthenticated,) def get_queryset(self): - return SocialAccount.objects.filter(user=self.request.user) + if self.request: + return SocialAccount.objects.filter(user=self.request.user) + else: + return SocialAccount.objects.none() def post(self, request, *args, **kwargs): accounts = self.get_queryset()