Python Django whitenoise版本控制不工作
我正在使用whitenoise with Waiteress来提供我的静态文件,但我无法让它使用版本化的静态文件。例如,如果我有一个foo.js,在运行collectstatic后,whitenoise会在我的静态文件夹中创建以下文件:Python Django whitenoise版本控制不工作,python,django,django-staticfiles,waitress,Python,Django,Django Staticfiles,Waitress,我正在使用whitenoise with Waiteress来提供我的静态文件,但我无法让它使用版本化的静态文件。例如,如果我有一个foo.js,在运行collectstatic后,whitenoise会在我的静态文件夹中创建以下文件: foo.js foo.js.gz foo.10a400e06df8.js foo.10a400e06df8.js.gz where 10a400e06df8 is the unique version code that whitenoise generated
foo.js
foo.js.gz
foo.10a400e06df8.js
foo.10a400e06df8.js.gz where 10a400e06df8 is the unique version code that whitenoise generated for me.
这是我的wsgi.py文件:
from django.core.wsgi import get_wsgi_application
# This is the default application
application = get_wsgi_application()
def white():
# This is an alternative WSGI app that wraps static content
from whitenoise.django import DjangoWhiteNoise
white = get_wsgi_application()
white = DjangoWhiteNoise(white)
return white
下面是我如何在模板中包含foo.js的:
{% load static from staticfiles %}
...
<script src="{% static "foo.js" %}" type="text/javascript"></script>
{%loadstaticfromstaticfiles%}
...
我按如下方式运行我的服务员服务器:
服务员服务——端口=8080——呼叫myapp.wsgi:white
当我加载我的页面时,我希望我能在浏览器中看到这一点
<script src="/static/foo.10a400e06df8.js" type="text/javascript"></script>
但我还是看到了
<script src="/static/foo.js" type="text/javascript"></script>
我错过什么了吗?在我的设置中,我确实有
STATICFILES_存储='whitenoise.django.GzipManifestStaticFilesStorage'
非常感谢您的帮助或建议 是否将
DEBUG
设置为True
?staticfiles应用程序仅在禁用调试模式时生成版本化URL