make runable on deal pc

This commit is contained in:
tlh 2025-10-21 11:10:17 +02:00
parent 0ed93d4649
commit 5003c6c1e3
3 changed files with 29 additions and 8 deletions

18
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Daphne ASGI server",
"type": "debugpy",
"request": "launch",
"module": "daphne",
"args": ["-b", "127.0.0.1", "-p", "8001", "project.config.asgi:application"],
"justMyCode": true,
"env": {
"DJANGO_SETTINGS_MODULE": "project.config.settings"
},
"cwd": "${workspaceFolder}",
"console": "integratedTerminal"
}
]
}

View File

@ -4,10 +4,12 @@ import sys
from pathlib import Path
def main():
project_dir = Path(__file__).resolve().parent / 'project'
if str(project_dir) not in sys.path:
sys.path.insert(0, str(project_dir))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.config.settings')
# Ensure the repository root (containing the 'project' package) is on sys.path.
repo_root = Path(__file__).resolve().parent
if str(repo_root) not in sys.path:
sys.path.insert(0, str(repo_root))
# Force correct settings module even if an old environment var (e.g. 'dali.settings') lingers.
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.config.settings'
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

View File

@ -5,11 +5,12 @@ from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
project_dir = Path(__file__).resolve().parent.parent
if str(project_dir) not in sys.path:
sys.path.insert(0, str(project_dir))
# Add repository root so 'project' package is importable regardless of CWD.
repo_root = Path(__file__).resolve().parent.parent.parent
if str(repo_root) not in sys.path:
sys.path.insert(0, str(repo_root))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.config.settings')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.config.settings'
http_app = get_asgi_application()