django 在服务器上收集静态

问题描述 投票:0回答:1

最近,我服务器上的数据库已经崩溃了。我想错误是在我这边的某个地方,我的鹡鸰数据库最终被清除了。我已经设法让我的 sqlite 数据库再次工作,但我的

collectstatic
仍然失败。

我尝试使用

static
重命名我的
mv static staticold
文件夹并重新运行
python manange.py collecstatic
但仍然失败。

错误消息如下:

Post-processing  'scss/main.css' failed! 

...
...
raise ValueError("The file '%s' could not be found with %r." % (filename, self))
ValueError: The file 'images/5f5a5b3515c4dd0c2c455925_110642301_938622823267359_7859124022958180678_n201.jpg' could not be found with <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0x7f00badf6f60>.`

我并不真正关心这些旧图像,尽管我希望我的 js 和 css 文件能够更新为

collectstatic

django nginx wagtail
1个回答
2
投票

您在使用

ManifestStaticFilesStorage
吗?如:

STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'

这听起来像是运行

collectstatic
时查找文件时出现问题时给出的错误。

如果您的设置中有该行,您可以注释掉该行,然后尝试运行

collectstatic
。然后,您只需确保将找不到的文件放置到位,或者在不需要时删除对它的引用,以便继续使用
ManifestStaticFilesStorage

我鼓励您使用

ManifestStaticFilesStorage
,因为它可以确保每次部署时您都有唯一版本的静态文件。这可确保用户始终收到最新版本的静态文件。

© www.soinside.com 2019 - 2024. All rights reserved.