django-etcd-settings
django-etcd-settings copied to clipboard
etcd_settings.loader.get_overwrites requires django.conf.settings
I tried to offload all of my deployment-specific settings in my DJANGO_SETTINGS_MODULE
to etcd_settings
but I'm not able to do so because the following line causes django.conf.settings
to be imported:
from etcd_settings.loader import get_overwrites
In etcd_settings/__init__.py
the EtcdSettingsProxy
is instantiated the moment my import happens. This in turn tries to get the DJES_*
settings. At this moment SECRET_KEY
is missing from the settings because it is one of the values I want to fetch through etcd_settings
.
So far, my solution has been to set SECRET_KEY
to some fake value before importing etcd_settings
but I don't think this is the best solution. IMO it would be better to move the instantiation of EtcdSettingsProxy
out of the package __init_.py
.
@fladi, thank you for the report. Yes, there're some restrictions, requiring a workaround, which you mentioned. We're looking into a ways of overcoming them
I think lazy evaluation of EtcdSettingsProxy
s __init__()
method should do the trick. Just using a check in its __getattr__
to load Django settings the first time a member is accessed. I'm busy right now, but I think I can come up with a PR in a few days.