def get(self, request, username): try: library = models.GameLibrary.objects.get(user__username=username) except models.GameLibrary.DoesNotExist: return Response(status=404) serializer = serializers.GameLibrarySerializer(library) return Response(serializer.data)
def get(self, request, username): try: user = User.objects.get(username=username) except User.DoesNotExist: try: user = User.objects.get(username__iexact=username) except User.DoesNotExist: return Response(status=404) except User.MultipleObjectsReturned: return Response(status=404) if user != request.user and not user.is_staff: return Response(status=404) library = models.GameLibrary.objects.get(user=user) serializer = serializers.GameLibrarySerializer(library) return Response(serializer.data)