Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (25.1k points)
recategorized by

I am trying to set up multiple setting files (development, production, ..) that include some base settings. Cannot succeed though. When I try to run ./manage.py runserver I am getting the following error:

(cb)clime@den /srv/www/cb $ ./manage.py runserver

ImproperlyConfigured: The SECRET_KEY setting must not be empty.

Here is my settings module:

(cb)clime@den /srv/www/cb/cb/settings $ ll

total 24

-rw-rw-r--. 1 clime clime 8230 Oct  2 02:56 base.py

-rw-rw-r--. 1 clime clime  489 Oct  2 03:09 development.py

-rw-rw-r--. 1 clime clime   24 Oct  2 02:34 __init__.py

-rw-rw-r--. 1 clime clime  471 Oct  2 02:51 production.py

If I add from base import * into /srv/www/cb/cb/settings/__init__.py (which is otherwise empty), it magically starts to work but I don't understand why. Anyone could explain to me what's going on here? It must be some python module magic.

1 Answer

0 votes
by (19.9k points)

I had the same error and it turned out to be a circular dependency between a module or class loaded by the settings and the settings module itself. In my case it was a middleware class which was named in the settings which itself tried to load the settings.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Oct 8, 2019 in Python by Rajesh Malhotra (19.9k points)
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...