gpt4 book ai didi

django - 操作系统错误 : [Errno 2] No such file or directory: '/tmp/MakeCalls/Static'

转载 作者:行者123 更新时间:2023-12-04 17:31:53 25 4
gpt4 key购买 nike

在执行“git push heroku master”(来自 Django 应用程序)时,推送被拒绝。我在下面包含了回溯。我可以禁用 collectstatic 但随后网页中的所有静态文件都丢失了。

当我跑 python manage.py collectstatic --noinput在我的本地服务器上,它没有给出任何错误。我在这上面花了两天时间,不知道我做错了什么。我已经包含了我的 .settings下面是静态文件。我正在使用白噪声,它在我的本地主机上运行良好。

我认为这与未找到的相对路径有关。但这不可能是因为我的本地服务器上没有错误?

remote:      $ python manage.py collectstatic --noinput
remote: Traceback (most recent call last):
remote: File "manage.py", line 10, in <module>
remote: execute_from_command_line(sys.argv)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
remote: utility.execute()
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
remote: self.fetch_command(subcommand).run_from_argv(self.argv)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
remote: self.execute(*args, **cmd_options)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
remote: output = self.handle(*args, **options)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
remote: collected = self.collect()
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
remote: for path, storage in finder.list(self.ignore_patterns):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 112, in list
remote: for path in utils.get_files(storage, ignore_patterns):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
remote: directories, files = storage.listdir(location)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 299, in listdir
remote: for entry in os.listdir(path):
remote: OSError: [Errno 2] No such file or directory: '/tmp/MakeCalls/Static'
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

静态文件:
STATICFILES_DIRS = ([
os.path.join(os.path.dirname(BASE_DIR), 'MakeCalls', 'Static'),
])

STATIC_URL = '/Static/'

STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'MakeCalls', 'MakeCalls', 'Static')



MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media')

MEDIA_URL = os.path.join(BASE_DIR, 'media/')


STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

最佳答案

所以我设法自己解决了这个问题。问题是我所有的静态文件都组织在 root/Static 中。并与 STATICFILES_DIRS 一起送达.但是,出于某种原因,Heroku 无法读取此内容。所以我把所有的静态文件放在 root/app/static并删除了 STATICFILES_DIRS在设置中,一切都奏效了!

关于django - 操作系统错误 : [Errno 2] No such file or directory: '/tmp/MakeCalls/Static' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41904685/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com