django-configurations
django-configurations copied to clipboard
How can i get a name of the currently loaded/used settings class?
I know I can use os.getenv but I'd like to be able to get the name of the currently used django-configurations settings class name in the code? How do I know I'm in Prod vs Development etc?
@striveforbest
This should have it:
from django.conf import settings
configuration_class_name = settings.CONFIGURATION.split('.')[-1]
We should document the fact that settings.CONFIGURATION exists, so I'm leaving this issue open.
@brianhelba that'd be amazing!
@brianhelba @striveforbest I think, that a utility for returning the configuration class itself would also be a nice feature... Even if it is as simple as:
from django.conf import settings
from django.utils.module_loading import import_string
def get_configuration_class():
return import_string(settings.CONFIGURATION)
It could be LRU cached, of course...