简体   繁体   中英

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). I am using whitenoise to handle the static files and done the correct configuration in settings.py file. 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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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