🐛 Make settings module available, first

This commit is contained in:
Brian Wiborg 2025-10-11 02:06:42 +02:00
parent 66176e9af7
commit 80163ce994
No known key found for this signature in database

View file

@ -40,6 +40,14 @@ class Project:
if str(self.project_path) not in sys.path:
sys.path.insert(0, str(self.project_path))
# Load settings.py
try:
self.settings = importlib.import_module("settings")
except Exception as e:
raise RuntimeError(
f"Failed to import project settings from {self.project_path}"
) from e
# Alias builtin apps as ohmyapi_<name>.
# We need this, because Tortoise app-names may not include dots `.`.
spec = importlib.util.find_spec("ohmyapi.builtin")
@ -57,14 +65,6 @@ class Project:
except ModuleNotFoundError:
pass
# Load settings.py
try:
self.settings = importlib.import_module("settings")
except Exception as e:
raise RuntimeError(
f"Failed to import project settings from {self.project_path}"
) from e
# Load installed apps
for app_name in getattr(self.settings, "INSTALLED_APPS", []):
self._apps[app_name] = App(self, name=app_name)