From b63ad40f546b2618d2224d129ee8bacf7afea032 Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Tue, 27 Dec 2022 18:53:49 -0500 Subject: [PATCH] Add ability to customise Django settings (#292) --- .gitignore | 1 + takahe/settings.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3323b44..c774867 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ /docs/_build /media/ /static-collected +/takahe/local_settings.py __pycache__/ api-test.* fly.toml diff --git a/takahe/settings.py b/takahe/settings.py index ba09d8e..cb4651b 100644 --- a/takahe/settings.py +++ b/takahe/settings.py @@ -64,9 +64,12 @@ class Settings(BaseSettings): #: Should django run in debug mode? DEBUG: bool = False - # Should the debug toolbar be loaded? + #: Should the debug toolbar be loaded? DEBUG_TOOLBAR: bool = False + #: Should we atttempt to import the 'local_settings.py' + LOCAL_SETTINGS: bool = False + #: Set a secret key used for signing values such as sessions. Randomized #: by default, so you'll logout everytime the process restarts. SECRET_KEY: str = Field(default_factory=lambda: secrets.token_hex(128)) @@ -405,3 +408,7 @@ TAKAHE_USER_AGENT = ( f"python-httpx/{httpx.__version__} " f"(Takahe/{__version__}; +https://{SETUP.MAIN_DOMAIN}/)" ) + +if SETUP.LOCAL_SETTINGS: + # Let any errors bubble up + from .local_settings import * # noqa