django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

251 views
Skip to first unread message

Peter Chen

unread,
Jan 4, 2018, 8:36:27 PM1/4/18
to Mezzanine Users

my secret key is already in local_settings.py, but I still get this error:

django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

I am using mezz 4.2.3

Peter Chen

unread,
Jan 4, 2018, 8:43:54 PM1/4/18
to Mezzanine Users
I am upgrading my mezzanine from 3.14 to 4.2.3 and upgrading my django from 1.6 to 1.8. 

I done all the structure change and put my secret key in local_settings

but when I do makemigration, it says my secret key is missing

Ryne Everett

unread,
Jan 7, 2018, 10:05:34 PM1/7/18
to mezzani...@googlegroups.com
I would follow the flow of execution to ensure your local_settings are
being sourced. For example, in the default project template:

1. You're running makemigrations through manage.py which defines
DJANGO_SETTINGS_MODULE as the settings.py file in your main project
directory.

settings_module = "%s.settings" % real_project_name("{{ project_name }}")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)

2. The settings.py looks for a local_settings.py file in the
main project directory and imports it.

f = os.path.join(PROJECT_APP_PATH, "local_settings.py")
if os.path.exists(f):
import sys
import imp
module_name = "%s.local_settings" % PROJECT_APP
module = imp.new_module(module_name)
module.__file__ = f
sys.modules[module_name] = module
exec(open(f, "rb").read())

If your project looks different than the default, that would be
noteworthy.

Peter Chen

unread,
Jan 8, 2018, 2:37:25 PM1/8/18
to Mezzanine Users
My project looks exactly like that. I followed the structure of 4.2.3 and modified the old settings.py according to the new settings.py

Ryne Everett

unread,
Jan 8, 2018, 5:15:18 PM1/8/18
to mezzani...@googlegroups.com
You might try raising an exception on the first line of local_settings.py just to make sure it’s being imported.
Reply all
Reply to author
Forward
0 new messages