def post(self, request, *args, **kwargs):
    serializer = self.serializer_class(data=request.data, context={'request': request})
    serializer.is_valid(raise_exception=True)
    user = serializer.validated_data['user']
    (token, _) = Token.objects.get_or_create(user=user)
    return Response({'token': token.key})
def post(self, request, *args, **kwargs):
    serializer = self.serializer_class(data=request.data, context={'request': request})
    serializer.is_valid(raise_exception=True)
    user = serializer.validated_data['user']
    (token, _) = Token.objects.get_or_create(user=user)
    return Response({'token': token.key})