From e7824d079a3348c4f3401f937a810fbbb991b5a2 Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 20 Jun 2024 20:43:05 +0200 Subject: [PATCH] refactor(settings): update paths and command execution Updated BASE_DIR and various paths in settings.py to simplify path handling. Modified management commands to use a consistent runner script (`quackscape-manage`) for improved clarity and maintainability. Addresses potential path issues and standardizes command usage. --- quackscape/management/commands/rundev.py | 5 +++-- quackscape/settings.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/quackscape/management/commands/rundev.py b/quackscape/management/commands/rundev.py index 4e249d6..aaae9d9 100644 --- a/quackscape/management/commands/rundev.py +++ b/quackscape/management/commands/rundev.py @@ -1,6 +1,7 @@ import asyncio from django.core.management.base import BaseCommand +from django.conf import settings class Command(BaseCommand): @@ -10,12 +11,12 @@ class Command(BaseCommand): async def start_django(self): # Command to run the Django development server - proc = await asyncio.create_subprocess_shell("python manage.py runserver") + proc = await asyncio.create_subprocess_shell(f"quackscape-manage runserver") stdout, stderr = await proc.communicate() async def start_celery(self): # Command to run the Celery worker - proc = await asyncio.create_subprocess_shell("python manage.py runworker") + proc = await asyncio.create_subprocess_shell(f"quackscape-manage runworker") stdout, stderr = await proc.communicate() async def run_both(self): diff --git a/quackscape/settings.py b/quackscape/settings.py index bf1fa22..12bae82 100644 --- a/quackscape/settings.py +++ b/quackscape/settings.py @@ -6,7 +6,7 @@ from urllib.parse import urlparse from django.urls import reverse_lazy # Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent +BASE_DIR = Path(__file__).resolve().parent ASK = AutoSecretKey("settings.ini") @@ -108,7 +108,7 @@ else: DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", + "NAME": "db.sqlite3", } } @@ -159,13 +159,13 @@ USE_TZ = True STATIC_URL = "static/" STATICFILES_DIRS = [ - BASE_DIR / "static", + "static", ] # Settings for uploaded files MEDIA_URL = "/media/" -MEDIA_ROOT = ASK.config.get("Quackscape", "MediaRoot", fallback=BASE_DIR / "media") +MEDIA_ROOT = ASK.config.get("Quackscape", "MediaRoot", fallback="media") if "S3" in ASK.config: DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"