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) - - - - -