0

i want to call two different class from one class in viewset of Django

class SocialLoginViewSet(viewsets.ModelViewSet):
    permission_classes = (permissions.AllowAny,)
    def social_login(self, request):
        email = request.data['email']
        if email:
            user_qs = MobileUser.objects.filter(email__iexact=email, is_active=True)
            if user_qs.exists():
                ExtendedJSONWebTokenAPIView.as_view()(self.request)
            else:
                NormalUserCreateViewSet.as_view()(self.request)

both viewset i am calling through Post method

Mayank Jha
  • 134
  • 7
  • You approach looks bad. This exception exists for reason and you incorrectly use DRF and its layers of abstraction. But if you don't care you can workaround it by using `request.raw_post_data` instead of `request.data`. – Raz Feb 02 '17 at 14:06

1 Answers1

0

For various reasons, Django only allows reading POST body once.

Check out this answer: Exception: You cannot access body after reading from request's data stream

Community
  • 1
  • 1
Dmitry Shilyaev
  • 713
  • 4
  • 10