From c615cd94aab87cd7d6bea4a5b2d6c611a6913d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeppe=20Vesterb=C3=A6k?= Date: Wed, 25 Feb 2015 16:52:51 +0100 Subject: [PATCH] DRF 3 bug: get HttpRequest from DRF request object. Similar to issue #43 --- rest_auth/registration/serializers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_auth/registration/serializers.py b/rest_auth/registration/serializers.py index 66473d5..2de467e 100644 --- a/rest_auth/registration/serializers.py +++ b/rest_auth/registration/serializers.py @@ -1,3 +1,4 @@ +from django.http import HttpRequest from rest_framework import serializers from requests.exceptions import HTTPError from allauth.socialaccount.helpers import complete_social_login @@ -11,6 +12,8 @@ class SocialLoginSerializer(serializers.Serializer): access_token = attrs.get('access_token') view = self.context.get('view') request = self.context.get('request') + if not isinstance(request, HttpRequest): + request = request._request if not view: raise serializers.ValidationError('View is not defined, pass it ' +