fix: profile work

This commit is contained in:
starnakin 2023-12-17 20:27:13 +01:00
parent 26a9152756
commit 6a537a9b68

View File

@ -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,