[英]Django whitenoise versioning not working
I am using whitenoise with waitress to serve my static files, but I could not get it to use the versioned static file. 我与女服务员一起使用whitenoise来提供我的静态文件,但是我无法使用它来使用版本化的静态文件。 For example, if I have a foo.js, after I run collectstatic, whitenoise creates the following files in my static folder: 例如,如果我有一个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 for me.
Here is my wsgi.py file: 这是我的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
Here is how I include the foo.js in my template: 这是我在模板中包括foo.js的方式:
{% load static from staticfiles %}
...
<script src="{% static "foo.js" %}" type="text/javascript"></script>
And I run my waitress server as follows: 然后按以下方式运行我的女服务员服务器:
waitress-serve --port=8080 --call myapp.wsgi:white 服务生--port = 8080-致电myapp.wsgi:white
When I load my page, I am expecting I would see this in my browser 加载页面时,我希望我会在浏览器中看到此信息
<script src="/static/foo.10a400e06df8.js" type="text/javascript"></script>
But I am still seeing 但我仍然看到
<script src="/static/foo.js" type="text/javascript"></script>
Did I missed anything? 我错过了什么吗? In my settings, I do have STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' 在我的设置中,我确实有STATICFILES_STORAGE ='whitenoise.django.GzipManifestStaticFilesStorage'
Any help or suggestions is highly appreciated! 任何帮助或建议,高度赞赏!
Is DEBUG
set to True
? DEBUG
设置为True
吗? The staticfiles app only generates versioned URLs when debug mode is disabled. 仅当禁用调试模式时,staticfiles应用程序才会生成版本化的URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.