OSError:[Errno 2]没有这样的文件或目录:'/ tmp / MakeCalls / Static' [英] OSError: [Errno 2] No such file or directory: '/tmp/MakeCalls/Static'

查看:168
本文介绍了OSError:[Errno 2]没有这样的文件或目录:'/ tmp / MakeCalls / Static'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当做git push heroku master(从Django应用程序)时,推送被拒绝。我已经在下面列出了追溯。我可以禁用收藏,但是所有的静态文件都从网页上丢失。

When doing 'git push heroku master' (from a Django app), the push gets rejected. I've included the traceback below. I can disable the collectstatic but then all the static files are missing from the webpage.

当我在本地服务器上运行 python manage.py collectstatic --noinput 时,它不会给出任何错误。我花了两天的时间,不知道我做错了什么。我已经为静态文件包含了我的 .settings 。我正在使用whitenoise,在本地主机上工作得很好。

When I run python manage.py collectstatic --noinput on my localserver it does not give any errors. I've spent the past two days on this, not sure what I'm doing wrong. I've included my .settings below for the staticfiles. I am using whitenoise which works perfectly fine on my localhost.

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

I think it has to do with a relative path that is not found. But that can't be it because there are no errors on my local server?

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:

Staticfiles:

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,并且这些文件都运行起来!

So I managed to fix this myself. The problem was that all my static files were organised in root/Static with and served with STATICFILES_DIRS. However for some reason Heroku can't read this. So I put all staticfiles in root/app/static and deleted the staticfiles_dirs in settings and it all worked!

这篇关于OSError:[Errno 2]没有这样的文件或目录:'/ tmp / MakeCalls / Static'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆