I am trying to configure several settings files (development, production, ..), which include some basic settings. However fails. When I try to run ./manage.py runserver , I get 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
Basic settings (contain SECRET_KEY):
(cb)clime@den /srv/www/cb/cb/settings $ cat base.py:
One of the settings files:
(cb)clime@den /srv/www/cb/cb/settings $ cat development.py from base import * DEBUG = True TEMPLATE_DEBUG = True ALLOWED_HOSTS = ['127.0.0.1', '31.31.78.149'] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'cwu', 'USER': 'clime', 'PASSWORD': '', 'HOST': '', 'PORT': '', } } MEDIA_ROOT = '/srv/www/cb/media/' STATIC_ROOT = '/srv/www/cb/static/' TEMPLATE_DIRS = ( '/srv/www/cb/web/templates', '/srv/www/cb/templates', )
Code in manage.py :
(cb)clime@den /srv/www/cb $ cat manage.py #!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cb.settings.development") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
If I add from base import * to /srv/www/cb/cb/settings/__init__.py (which is otherwise empty), it magically starts working, but I don’t understand why. Can anyone explain to me what is going on here? This should be the magic of the python module.
EDIT: Everything also starts to work if I delete this line with base.py
django.template.loader.add_to_builtins('web.templatetags.cb_tags')
If I remove this line from web.templatetags.cb_tags, it will also start working:
from endless_pagination.templatetags import endless
I guess this is because it ultimately leads to
from django.conf import settings PER_PAGE = getattr(settings, 'ENDLESS_PAGINATION_PER_PAGE', 10)
In this way, he creates some weird circular things and a game.