Closed jacobh closed 11 years ago
I added
from configurations import importer
importer.install()
to the top of my settings file and I now get the error
ImproperlyConfigured: The SECRET_KEY setting must not be empty.
I'm not sure if my issues are related to https://github.com/jezdez/django-configurations/issues/27 . I'm inclined to think not as my settings file doesn't really do anything funky (as far as I know) https://gist.github.com/hzy/4c870d217d80bb398007
@hzy I wasn't able to reproduce the problem you describe. What version of django-configurations do you run?
You definitely don't need the installer to be imported in your settings and called.
What happens if you comment out the import and call of djcelery.setup_loader()
?
regarding gizmag_secrets.settings.Secrets
, does its module have an import for django.conf.settings
?
django-configurations==0.6 and Django==1.5.4.
I tried the different combinations of having djcelery.setup_loader()
commented out and it made no difference.
gizmag_secrets.settings entire contents is
class Secrets(object):
EMAIL_HOST_USER = ...
EMAIL_HOST_PASSWORD = ...
...
I think I found the issue. Just reading the traceback I noticed mention of gizmag/init.py. that file contains this little permission trick. When I commented it out gunicorn fired up instantly.
Maybe this is being called by gunicorn before configurations has a chance to kick in?
# register a signal do update permissions every migration.
# This is based on app django_extensions update_permissions command
from south.signals import post_migrate
def update_permissions_after_migration(app, **kwargs):
"""
Update app permission just after every migration.
This is based on app django_extensions update_permissions management command.
"""
from django.conf import settings
from django.db.models import get_app, get_models
from django.contrib.auth.management import create_permissions
create_permissions(get_app(app), get_models(), 2 if settings.DEBUG else 0)
post_migrate.connect(update_permissions_after_migration)
Aha! That must be it. When you try to import a module in a package like gizmag.wsgi
(as does gunicorn during startup) it'll also import the gismag/__init__.py
first, triggering the settings loading cycle. It's generally a good idea to not do that and instead put signal connection inside of models.py modules, which are guarenteed to be loaded by Django after the settings system has initialized.
I'm going to close this as a WONTFIX, but I'll keep this in mind in case further reports are coming in with similar situations.
Thanks for the help :)
Gladly, @hzy!
Hi,
I've been racking my brain all day with this issue and I've been unable to get it working.
We're in the process of switching over to using django-configurations for our project and for some reason it appears gunicorn isn't able to pick up the settings. Running the project with
python manage.py runserver
works perfectly.My code is as follows:
gizmag/settings.py
gizmag/wsgi.py
manage.py
And the error I receive if I don't explicitly export my settings module / configuration
And when I do explicitly define them (I also don't know why my default environment variables aren't working)
Thanks in advance for any help! and I'm so sorry if it turns out I've skipped over part of the documentation.