【发布时间】:2018-04-24 10:37:47
【问题描述】:
我正在尝试将应用升级到 Django 1.11,但遇到collectstatic 的问题。
旧版本:
django 1.8.17
django-storages 1.5.1
新版本:
django 1.11.12
django-storages 1.6.6
存储:
class StaticS3BotoStorage(ManifestFilesMixin, S3BotoStorage):
location = 'static'
file_overwrite = True
preload_metadata = True
或
class StaticS3BotoStorage(CachedFilesMixin, S3BotoStorage):
location = 'static'
file_overwrite = True
preload_metadata = True
在旧版本中,collectstatic 工作正常,包括 collectstatic --clear。
升级后,collectstatic --clear 失败(没有文件被删除)。
collectstatic 确实复制文件,但是,有时它会创建同一文件的两个版本。在这个特定的例子中,我得到了base.hash1.css 和base.hash2.css。 base.hash2.css 为空,因此页面打开,但未正确呈现。
如果我不使用 CachedFilesMixin 或 ManifestFilesMixin,collectstatic 可以正常工作,但 clear 仍然失败。
我测试了 django 1.11 和 django-storages 的不同组合,但它们的行为似乎都一样。
其他人是否遇到过类似的问题?
【问题讨论】:
标签: python django django-storage