Forums

Django SECRET_KEY ImproperlyConfigured

Hello,

When trying to run app I'm still getting following error:

2021-04-10 19:01:17,612: Error running WSGI application
2021-04-10 19:01:17,621: django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment variable

I have .env file, placed next to manage.py, with SECRET_KEY settings inside.

When I'm running ./manage.py shell from the console I can import settings from django.conf module and SECRET_KEY is there.

I can also run ./manage.py runserver 127.0.0.1:9000 and I'm getting no error... any ideas what's going on?

Link to my settings.py.

You need to load your secrets from the .env file in the wsgi file. take a look at How to set environment variables for your web apps (for SECRET_KEY etc) | PythonAnywhere help

Thank you. It worked.

Awesome!