Describe the bug
In load_janeway_settings the settings referred to by DJANGO_SETTINGS_MODULE are merged into the base core.janeway_global_settings.
The method for merging involves appending to any existing sequence settings, and applying new keys to existing dictionaries. This means it's almost impossible to completely override sequence- or dict-based settings, and this behaviour is also potentially counter-intuitive.
For example, my attempt to insert a new middleware class into the existing Janeway default middleware list results in the default middleware being included twice:
from core import janeway_global_settings
MIDDLEWARE_CLASSES = list(janeway_global_settings.MIDDLEWARE_CLASSES)
MIDDLEWARE_CLASSES.insert(
MIDDLEWARE_CLASSES.index("django.middleware.security.SecurityMiddleware") + 1,
"whitenoise.middleware.WhiteNoiseMiddleware",
)
Janeway version
This is on master, currently 7739efb.
Expected behavior
One of three things:
- A setting in
DJANGO_SETTINGS_MODULE completely overrides the corresponding setting in global_janeway_settings, but the current custom configure_settings() behaviour continues, or
- The current
configure_settings() approach is removed, and from core.global_janeway_settings import * can be used in DJANGO_SETTINGS_MODULE to the same effect, making things more explicit, with no backwards-compatibility, or
load_janeway_settings could detect whether global_janeway_settings is *-imported into DJANGO_SETTINGS_MODULE — as the new preferred approach — and disable the settings-merging behavour. This would provide backwards-compatibility for the current behaviour.
Describe the bug
In load_janeway_settings the settings referred to by
DJANGO_SETTINGS_MODULEare merged into the basecore.janeway_global_settings.The method for merging involves appending to any existing sequence settings, and applying new keys to existing dictionaries. This means it's almost impossible to completely override sequence- or dict-based settings, and this behaviour is also potentially counter-intuitive.
For example, my attempt to insert a new middleware class into the existing Janeway default middleware list results in the default middleware being included twice:
Janeway version
This is on master, currently 7739efb.
Expected behavior
One of three things:
DJANGO_SETTINGS_MODULEcompletely overrides the corresponding setting inglobal_janeway_settings, but the current customconfigure_settings()behaviour continues, orconfigure_settings()approach is removed, andfrom core.global_janeway_settings import *can be used inDJANGO_SETTINGS_MODULEto the same effect, making things more explicit, with no backwards-compatibility, orload_janeway_settingscould detect whetherglobal_janeway_settingsis *-imported intoDJANGO_SETTINGS_MODULE— as the new preferred approach — and disable the settings-merging behavour. This would provide backwards-compatibility for the current behaviour.