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.
This commit is contained in:
parent
d8f8ae30e3
commit
e7824d079a
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
@ -10,12 +11,12 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
async def start_django(self):
|
async def start_django(self):
|
||||||
# Command to run the Django development server
|
# 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()
|
stdout, stderr = await proc.communicate()
|
||||||
|
|
||||||
async def start_celery(self):
|
async def start_celery(self):
|
||||||
# Command to run the Celery worker
|
# 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()
|
stdout, stderr = await proc.communicate()
|
||||||
|
|
||||||
async def run_both(self):
|
async def run_both(self):
|
||||||
|
|
|
@ -6,7 +6,7 @@ from urllib.parse import urlparse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# 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")
|
ASK = AutoSecretKey("settings.ini")
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ else:
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.sqlite3",
|
"ENGINE": "django.db.backends.sqlite3",
|
||||||
"NAME": BASE_DIR / "db.sqlite3",
|
"NAME": "db.sqlite3",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,13 +159,13 @@ USE_TZ = True
|
||||||
STATIC_URL = "static/"
|
STATIC_URL = "static/"
|
||||||
|
|
||||||
STATICFILES_DIRS = [
|
STATICFILES_DIRS = [
|
||||||
BASE_DIR / "static",
|
"static",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Settings for uploaded files
|
# Settings for uploaded files
|
||||||
|
|
||||||
MEDIA_URL = "/media/"
|
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:
|
if "S3" in ASK.config:
|
||||||
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
|
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
|
||||||
|
|
Loading…
Reference in a new issue