From 2b4ec6c006201ccdf9d864267d3c6394f9268d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Juh=C3=A1s?= <xjuhas@fi.muni.cz> Date: Mon, 27 May 2024 10:42:11 +0200 Subject: [PATCH] Resolve "Move database file to data" --- exercise/lib/export_import.py | 2 +- ttxbackend/settings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exercise/lib/export_import.py b/exercise/lib/export_import.py index 26e69269..e4e5954f 100644 --- a/exercise/lib/export_import.py +++ b/exercise/lib/export_import.py @@ -79,7 +79,7 @@ def import_database(uploaded_file: UploadedFile): settings.EXPORT_IMPORT_STORAGE, f"import_{timestamp}" ) os.makedirs(dir_path, exist_ok=True) - os.makedirs(settings.FILE_STORAGE) + os.makedirs(settings.FILE_STORAGE, exist_ok=True) with ZipFile(uploaded_file.file) as zip_file: zip_file.extractall(dir_path) diff --git a/ttxbackend/settings.py b/ttxbackend/settings.py index 60035714..8747c3bc 100644 --- a/ttxbackend/settings.py +++ b/ttxbackend/settings.py @@ -94,10 +94,11 @@ ASGI_APPLICATION = "ttxbackend.asgi.application" # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases +DATA_STORAGE = "data" DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", - "NAME": os.path.join(BASE_DIR, "db.sqlite3"), + "NAME": os.path.join(BASE_DIR, DATA_STORAGE, "db.sqlite3"), } } @@ -158,7 +159,6 @@ REST_FRAMEWORK = { DEFAULT_AUTO_FIELD = "django.db.models.AutoField" DEFINITION_EXAMPLE_STORAGE = "definitions" -DATA_STORAGE = "data" DEFINITION_FILE_STORAGE = "files" DEFINITION_CONTENT_STORAGE = "content" FILE_STORAGE = os.path.join(DATA_STORAGE, DEFINITION_FILE_STORAGE) -- GitLab