1

我正在尝试在heroku上运行collectstatic。当我收到此错误时:

remote: 'component ({})'.format(final_path, base_path)) 
remote: django.core.exceptions.SuspiciousFileOperation: The joined path (/tmp/build_4652acfe079723bc273763513a187201/fonts/glyphicons-halflings-regular.eot) is located outside of the base path component (/tmp/build_4652acfe079723bc273763513a187201/staticfiles) 

我想也许我错过了一些与 collectstatic 相关的东西,所以我在本地运行它,并得到了完全相同的错误。

然后我就去找了。我发现:

/home/malikarumi/Projects/aishah/jamf35/staticfiles/bootstrap/fonts/glyphicons-halflings-regular.eot

/home/malikarumi/Projects/aishah/jamf35/static/bootstrap/fonts/glyphicons-halflings-regular.eot

我的设置:

STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static/bootstrap/fonts/'),

那里有一张票,但它似乎与路径有关,我认为我的路径没有任何问题,https://code.djangoproject.com/ticket/27201 另一个处理文件,可能更接近我的问题,因为它与创建的 tmp 文件有关,但我真的看不出来: https ://code.djangoproject.com/ticket/26644

我应该注意,我还查看了Django:连接路径位于基本路径组件之外Django:如何允许可疑文件操作/复制文件,以及 Django | 加入的路径位于基本路径组件 {% static img.thumbnail.url %} 之外,带有 whitenoise 的错误 400,但它们似乎更多地是关于 MEDIA ROOT 问题。

我不确定修复是什么,在这里。请指教。谢谢。

4

1 回答 1

3

你的STATICFILES_DIRS设置看起来很奇怪。你确定你不想要这个吗?

STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'),]

问题是您的 CSS 文件之一具有在静态目录之外解析的相对引用,我认为这是因为您拥有static/bootstrap/fonts应该拥有的static.

于 2017-09-14T13:20:15.760 回答