Heroku尝试部署python网站,,manage.py collestatic --noninput"



我使用Python、JS、React、Django创建了一个网站。当我通过github部署在Heroku上时,出现了一个错误:

-----> Determining which buildpack to use for this app
!     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
Detected buildpacks: Python,Node.js
See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
-----> Python app detected
-----> Using Python version specified in Pipfile.lock
cp: cannot stat '/tmp/build_02d1f320/requirements.txt': No such file or directory
-----> Installing python-3.9.7
-----> Installing pip 20.2.4, setuptools 57.5.0 and wheel 0.37.0
-----> Installing dependencies with Pipenv 2020.11.15
Installing dependencies from Pipfile.lock (dee4f1)...
-----> Installing SQLite3
-----> $ python leadmanager/manage.py collectstatic --noinput
Traceback (most recent call last):
File "/tmp/build_02d1f320/leadmanager/manage.py", line 22, in <module>
main()
File "/tmp/build_02d1f320/leadmanager/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
collected = self.collect()
File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
handler(path, prefixed_path, storage)
File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 338, in copy_file
if not self.delete_file(path, prefixed_path, source_storage):
File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 248, in delete_file
if self.storage.exists(prefixed_path):
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/files/storage.py", line 318, in exists
return os.path.exists(self.path(name))
File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 38, in path
raise ImproperlyConfigured("You're using the staticfiles app "
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
!     Error while running '$ python leadmanager/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 

这是我的github存储库:在这里输入链接描述

当我尝试通过localhost:8000运行我的网站时,它运行得很好,但现在,当我尝试在Heroku上部署时,出现了这个错误。我的数据库是用django构建的。请帮帮我,谢谢!!

根据错误追溯,未配置STATIC_ROOTurl。

您需要在django应用程序settings.py脚本中配置静态文件目录url,例如:STATIC_ROOT = BASE_DIR + "../your-static-dir"

之后,您可以添加并在Heroku上运行collect static命令heroku run python manage.py collectstatic --dry-run --noinput

还可以考虑查看这个问题的陈述,了解有关配置静态&媒体URL。Django 301和403在生产中禁止我的静态文件出现错误

最新更新