Collectstatic 上的 Django 版本控制静态文件

Django versioning static files at collectstatic

我正在寻找一种方法来为在 collectstatic 期间找到的所有静态文件添加一个版本。

目标是强制重新加载缓存的静态文件。例如,如果静态文件源是 src="/jquery/jquery.min.js" 我想在 collectstatic 之后添加日期以具有 src="/jquery/jquery.min.js?date=2015-10-1T10:31:42"

最好的方法是什么?

编辑:我使用的是 django 1.4.2

编辑 2:最终,我将我的应用程序更新到了 django 1.8.5

一种可能是使用 django-versioned-static:

This little apps helps to manage your staticfiles when you need to minify them for production use. Moreover, it is capable of versioning the assets so that whenever you need to alter the static files, users won’t be given old file from the browser cache.

使用 ManifestStaticFilesStorage 会有帮助。