错误:django.core.exceptions.impropertlyconfigured:密钥设置不能为空。将应用程序部署到heroku时
我是一个初学者,尝试使用Heroku部署我的第一个Django项目,但现在在运行git错误:django.core.exceptions.impropertlyconfigured:密钥设置不能为空。将应用程序部署到heroku时,django,heroku,Django,Heroku,我是一个初学者,尝试使用Heroku部署我的第一个Django项目,但现在在运行gitpush master Heroku命令时遇到了空密钥问题: 已在本地计算机上检查,但我的应用程序在本地计算机上运行,没有任何问题。 我在这个网站上查看了其他解决方案,它们似乎都没有帮助我 这是错误 remote: -----> $ python manage.py collectstatic --noinput remote: Traceback (most recent call las
push master Heroku
命令时遇到了空密钥问题:
已在本地计算机上检查,但我的应用程序在本地计算机上运行,没有任何问题。
我在这个网站上查看了其他解决方案,它们似乎都没有帮助我
这是错误
remote: -----> $ python manage.py collectstatic --noinput
remote: Traceback (most recent call last):
remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 224, in fetch_command
remote: app_name = commands[subcommand]
remote: KeyError: 'collectstatic'
remote: During handling of the above exception, another exception occurred:
remote: Traceback (most recent call last):
remote: File "manage.py", line 21, in <module>
remote: main()
remote: File "manage.py", line 17, in main
remote: execute_from_command_line(sys.argv)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
remote: utility.execute()
remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
remote: self.fetch_command(subcommand).run_from_argv(self.argv)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 231, in fetch_command
remote: settings.INSTALLED_APPS
remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
remote: self._setup(name)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup
remote: self._wrapped = Settings(settings_module)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 161, in __init__
remote: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
remote: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
remote:
remote: ! Error while running '$ python manage.py collectstatic --noinput'.
remote: See traceback above for details.
remote:
remote: You may need to update application code to resolve this error.
remote: Or, you can disable collectstatic for this application:
remote:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote: https://devcenter.heroku.com/articles/django-assets
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
这是本地计算机服务器的运行状态
(venv) E:\MY projects\Django_Blog\blog>py manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
January 18, 2020 - 17:41:29
Django version 3.0.1, using settings 'blog.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
提前感谢您是否在heroku服务器设置中添加了环境变量?还要检查您是否为密钥提供了正确的拼写。刚才在你的设置文件中添加了“秘密密钥”,解决了我的问题。“secret_KEY”是环境变量中指定的变量。感谢You@NagArjun你能进一步解释一下你需要调整什么来解决这个问题吗?我在digital ocean上遇到了这样的构建错误。@ThomasByers刚刚在环境变量中添加了“SECRET_KEY”和其他必需变量。
(venv) E:\MY projects\Django_Blog\blog>py manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
January 18, 2020 - 17:41:29
Django version 3.0.1, using settings 'blog.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.