From ef3e03f22c151e4a21d1241a5cc24d15aa2c08ef Mon Sep 17 00:00:00 2001 From: mi1468 Date: Tue, 27 May 2025 14:48:29 +0330 Subject: [PATCH] get spaces --- core/views/userView.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/views/userView.py b/core/views/userView.py index 28c7325..99e5d50 100644 --- a/core/views/userView.py +++ b/core/views/userView.py @@ -1163,6 +1163,15 @@ def addSpace(request): data = request.data.copy() data['userId'] = request.user.id # Automatically assign the authenticated user + # Retrieve the AssetBundleRoom instance from the provided ID + try: + asset_bundle_room = AssetBundleRoom.objects.get(id=data['assetBundleRoomId']) + except AssetBundleRoom.DoesNotExist: + return Response({"detail": "AssetBundleRoom not found."}, status=status.HTTP_404_NOT_FOUND) + + # Assign the AssetBundleRoom instance to the data + data['assetBundleRoomId'] = asset_bundle_room + # Pass the request object to the serializer context serializer = SpaceSerializer(data=data) @@ -1179,8 +1188,3 @@ def addSpace(request): else: # If validation fails, return the errors return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - - - - -