简体   繁体   English

将 Django 应用程序部署到 Heroku 时出错

[英]Getting an error when deploying a Django app to Heroku

I am trying to deploy a django app but I am getting a push rejected error(Traceback attached).我正在尝试部署 django 应用程序,但出现推送被拒绝错误(附加回溯)。 I am using whitenoise to handle the static files and done the correct configuration in settings.py file.我正在使用白噪声来处理静态文件并在 settings.py 文件中进行了正确的配置。 This error has really been bugging me .这个错误一直困扰着我。

-----> $ python manage.py collectstatic --noinput
       Traceback (most recent call last):
         File "manage.py", line 21, in <module>
           main()
         File "manage.py", line 17, in main
           execute_from_command_line(sys.argv)
         File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
           utility.execute()
         File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 377, in execute
           django.setup()
         File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
           apps.populate(settings.INSTALLED_APPS)
         File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 91, in populate
           app_config = AppConfig.create(entry)
         File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 116, in create
           mod = import_module(mod_path)
         File "/app/.heroku/python/lib/python3.6/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 953, in _find_and_load_unlocked
       ModuleNotFoundError: No module named 'whitenoise'
 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.
       You may need to update application code to resolve this error.
       Or, you can disable collectstatic for this application:
          $ heroku config:set DISABLE_COLLECTSTATIC=1
       https://devcenter.heroku.com/articles/django-assets
 !     Push rejected, failed to compile Python app.
 !     Push failed

在您的开发环境中,运行pip freeze > requirements.txt这将添加您当前安装的所有模块,并且假设您的开发环境具有其所有依赖项,将使 Heroku 能够安装所有需要的模块。

问题是我没有在要部署的应用程序上禁用静态我运行以下命令 heroku config:set DISABLE_COLLECTSTATIC=1 -app 'appname'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM