コード例 #1
0
    def post(self, request):
        data = request.data

        if data['password'] != data['password_confirm']:
            raise exceptions.APIException('Passwords do not match!')

        data[
            'is_ambassador'] = 'api/ambassador' in request.path  # se chiamo url ambassador sono amabssador

        serializer = UserSerializer(data=data)
        serializer.is_valid(raise_exception=True)
        serializer.save()
        return Response(serializer.data)
コード例 #2
0
 def put(self, request, pk=None):
     user = request.user
     serializer = UserSerializer(user, data=request.data, partial=True)
     serializer.is_valid(raise_exception=True)
     serializer.save()
     return Response(serializer.data)