Can't access variables from django.conf.settings in realtime.

I am trying to access settings variables from a custom module that is initialized in settings.

Here’s the code.

AUTH0_DOMAIN = "***"

In the last line of the code, AuthEngine tries to fetch all the variables defined before that line. But testing using hasattr always returns False. In the __init__() of AuthEngine, I tried to look at the content of django.conf.settings and found that none of the variables I defined in the settings was there.

I guess as the last line of the code above is getting executed, the updated settings are not available to the rest of the files yet. How to get the updated settings?


That is correct - since you have:

The instance of AuthEngine is going to be created when the module file is imported, which is before the settings module applies those settings to the conf.settings

I don’t know what the purpose or function is of this object, but I think you’re likely going to have more success if you perform this initialization in the AppConfig.ready method.

1 Like