Esempio n. 1
0
 def update_profile(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         serializer = UserProfileSerializer(instance,data=request.data)
         serializer.is_valid(raise_exception=True)
         instance = serializer.save()
         serializer = UserSerializer(instance)
         return Response(serializer.data)
     except serializers.ValidationError:
         print(traceback.print_exc())
         raise
     except ValidationError as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(repr(e.error_dict))
     except Exception as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(str(e))
Esempio n. 2
0
 def profiles(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         serializer = UserProfileSerializer(instance.profiles.all(),
                                            many=True)
         return Response(serializer.data)
     except serializers.ValidationError:
         print(traceback.print_exc())
         raise
     except ValidationError as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(repr(e.error_dict))
     except Exception as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(str(e))
Esempio n. 3
0
 def update_profile(self, request, *args, **kwargs):
     try:
         instance = self.get_object()
         serializer = UserProfileSerializer(instance, data=request.data)
         serializer.is_valid(raise_exception=True)
         instance = serializer.save()
         serializer = UserSerializer(instance)
         return Response(serializer.data)
     except serializers.ValidationError:
         print(traceback.print_exc())
         raise
     except ValidationError as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(repr(e.error_dict))
     except Exception as e:
         print(traceback.print_exc())
         raise serializers.ValidationError(str(e))