我正在使用自定义静态文件存储:
class StaticFilesStorage(CachedFilesMixin, S3BotoStorage):
pass
(cachedFileMixin用于缓存破坏)。你知道吗
我的问题是,当我的模板中有{% static "file_that_does_not_exist.jpg" %}
时,模板没有呈现,我得到一个异常
ValueError: The file 'file_that_does_not_exist.jpg' could not be found with <StaticFilesStorage object at 0x03AE4C70>.
它失败是因为文件不在S3上,所以S3BotoStorage无法提供服务,但这意味着如果徽标.jpg文件由于某种原因丢失了,然后整个网站都瘫痪了,这不好。。你知道吗
有没有办法强迫{% static %}
默默地失败?你知道吗
现在这对我来说很有效:
这会覆盖
S3BotoStorage.exists()
,因此{% static %}
不会引发异常并生成s3url(这会将404提供给浏览器,但没关系)。你知道吗相关问题 更多 >
编程相关推荐