我正在尝试在本地运行我的 Heroku 应用程序并按照此处的说明进行操作。
当我尝试运行以下命令时:
python manage.py collectstatic
我有这个错误:
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.
SECRET_KEY 已在 Heroku 上声明为配置变量。
我已经联系了 Heroku,但仍然没有回复,所以也许这里的某个人可以在他们面前找到解决此错误的方法。
我想使用与 web 相同的版本在本地运行此应用程序,因此添加SECRET_KEY
对settings.py
我来说不是一条路线。
我settings.py
的配置是这样的:
from decouple import config
SECRET_KEY = config('SECRET_KEY')