I am trying to run my Heroku app locally and followed the instructions from here.
When I tried to run the following command:
python manage.py collectstatic
I've got this error:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Python36-32\lib\site-packages\django\core\management\__init__.py", line 317, in execute
settings.INSTALLED_APPS
File "C:\Python36-32\lib\site-packages\django\conf\__init__.py", line 56, in __getattr__
self._setup(name)
File "C:\Python36-32\lib\site-packages\django\conf\__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python36-32\lib\site-packages\django\conf\__init__.py", line 106, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\robina\Ubelt-Dorm\ph_dorms\settings.py", line 25, in <module>
SECRET_KEY = config('SECRET_KEY')
File "C:\Python36-32\lib\site-packages\decouple.py", line 197, in __call__
return self.config(*args, **kwargs)
File "C:\Python36-32\lib\site-packages\decouple.py", line 85, in __call__
return self.get(*args, **kwargs)
File "C:\Python36-32\lib\site-packages\decouple.py", line 70, in get
raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value.
The SECRET_KEY has been declared as a Config Variable on Heroku.
I've reached out to Heroku but still no response so maybe someone from here could find the solution to this error before them.
I want to run this app locally with the same version as web so adding SECRET_KEY
on the settings.py
is not a route for me.
My settings.py
is configured this way:
from decouple import config
SECRET_KEY = config('SECRET_KEY')
You can set local env vars by adding them to a .env
file, and then starting your development server via heroku local
. This will convert all NAME=value
lines from .env
to env vars and make then available to your app. You can then add .env
to your .gitignore
, as this is only required on your local machine. See https://devcenter.heroku.com/articles/heroku-local#set-up-your-local-environment-variables for more details.