django.conf.settings is hard to override
|Reported by:||Owned by:||hugo|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
if you want to do anything with settings, the settings module is (unnecessarily) hard to work with.
Configuration shouldn't be a module, but instead an object in a module. And configuration setup shouldn't happen implicitly on import, but instead when specifically invoked (passing in the module name for the settings). Then the standard server setup can invoke this settings setup using the normal environmental variable. Or other people can do other things.
Also, there should be a way to swap in new settings dynamically, using threadlocal storage. But at least if the object is there you can monkeypatch something that does swapping. Hacking in swappable modules is harder.
AFAICT, everyone does "from django.conf import settings", so pottentially settings can be an object in the django.conf module, without much impact to existing code. Or a new module with an object can be created, and django.conf.settings is a shell fake module around that.