From 8c040b26d37183e9b6d923c6ca6a96b03f826470 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 2 Mar 2022 18:22:24 +0900 Subject: [PATCH] Update default database location in cli --- backend/cli.py | 5 +++++ backend/config/settings/base.py | 2 +- backend/pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/cli.py b/backend/cli.py index 3eeb5cb4..20476164 100644 --- a/backend/cli.py +++ b/backend/cli.py @@ -3,14 +3,19 @@ import multiprocessing import os import platform import sys +from pathlib import Path import django from django.core import management from .config.celery import app +DOCCANO_HOME = os.path.expanduser(os.environ.get("DOCCANO_HOME", "~/doccano")) +Path(DOCCANO_HOME).mkdir(parents=True, exist_ok=True) os.environ["STANDALONE"] = "True" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") +os.environ.setdefault("DATABASE_URL", os.path.join(f"sqlite:///{DOCCANO_HOME}", "db.sqlite3")) +os.environ.setdefault("MEDIA_ROOT", os.path.join(DOCCANO_HOME, "media")) base = os.path.abspath(os.path.dirname(__file__)) sys.path.append(base) django.setup() diff --git a/backend/config/settings/base.py b/backend/config/settings/base.py index 2c140efd..963c1652 100644 --- a/backend/config/settings/base.py +++ b/backend/config/settings/base.py @@ -239,7 +239,7 @@ if not EMAIL_HOST: # User media files -MEDIA_ROOT = path.join(BASE_DIR, "media") +MEDIA_ROOT = env("MEDIA_ROOT", path.join(BASE_DIR, "media")) MEDIA_URL = "/media/" # Filepond settings diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 63e3a7fe..fcb84e09 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -55,7 +55,7 @@ auto-labeling-pipeline = "^0.1.21" dj-rest-auth = "^2.2.3" django-drf-filepond = "^0.4.1" celery = "^5.2.3" -django-celery-results = "^2.2.0" +django-celery-results = "2.2.0" SQLAlchemy = "^1.4.31" waitress = "^2.0.0" django-health-check = "^3.16.5"