From 6a537a9b689ae4d9244fb94f66e48c09acb7a915 Mon Sep 17 00:00:00 2001 From: starnakin Date: Sun, 17 Dec 2023 20:27:13 +0100 Subject: [PATCH] fix: profile work --- profiles/viewsets.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/profiles/viewsets.py b/profiles/viewsets.py index 7dc8d49..8b82afd 100644 --- a/profiles/viewsets.py +++ b/profiles/viewsets.py @@ -18,7 +18,9 @@ class ProfileViewSet(viewsets.ModelViewSet): permission_classes = (permissions.IsAuthenticatedOrReadOnly,) def retrieve(self, request: HttpRequest, pk=None): - instance = self.get_object() + if (self.queryset().filter(pk=pk)): + return Response({"detail": "Profile not found."}, status=status.HTTP_404_NOT_FOUND) + instance = self.queryset().get(pk=pk) instance.avatar_url.name = instance.avatar_url.name[instance.avatar_url.name.find("static") - 1:] return Response(self.serializer_class(instance).data, status=status.HTTP_200_OK) @@ -53,7 +55,6 @@ class MyProfileViewSet(viewsets.ModelViewSet): profile.save() def retrieve(self, request: HttpRequest, pk=None): - print("test") instance: ProfileModel = self.get_object() instance.avatar_url.name = instance.avatar_url.name[instance.avatar_url.name.find("static") - 1:] return Response(self.serializer_class(instance).data,