From 12ec9619a612067fb4b360110f4d9edbb18fd5dd Mon Sep 17 00:00:00 2001 From: karthikmurakonda Date: Wed, 11 Oct 2023 06:29:44 +0530 Subject: [PATCH] fix directory if not exists --- CDC_Backend/APIs/adminViews.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CDC_Backend/APIs/adminViews.py b/CDC_Backend/APIs/adminViews.py index 657a408..b951605 100644 --- a/CDC_Backend/APIs/adminViews.py +++ b/CDC_Backend/APIs/adminViews.py @@ -425,7 +425,8 @@ def generateCSV(request, id, email, user_type): applications = PlacementApplication.objects.filter(placement=opening) filename = generateRandomString() if not os.path.isdir(STORAGE_DESTINATION_APPLICATION_CSV): - os.mkdir(STORAGE_DESTINATION_APPLICATION_CSV) + # create directory if not present already even if first directory is not present + os.makedirs(STORAGE_DESTINATION_APPLICATION_CSV, exist_ok=True) destination_path = STORAGE_DESTINATION_APPLICATION_CSV + filename + ".csv" f = open(destination_path, 'w') writer = csv.writer(f)