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)
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)