🐛 Make settings module available, first
This commit is contained in:
parent
66176e9af7
commit
80163ce994
1 changed files with 8 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue