我使用whitenoise和侍者服务我的静态文件,但我无法让它使用版本的静态文件。例如,如果我有一个foo.js,在运行收藏品之后,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.这是我的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>我运行我的服务员服务器如下:
服务员-服务-端口=8080-呼叫myapp.wsgi:white
当我加载我的页面时,我希望在我的浏览器中看到这个
<script src="/static/foo.10a400e06df8.js" type="text/javascript"></script>但我还是看到
<script src="/static/foo.js" type="text/javascript"></script>我错过了什么吗?在我的设置中,我确实有'whitenoise.django.GzipManifestStaticFilesStorage‘= STATICFILES_STORAGE
任何帮助或建议都是非常感谢的!
发布于 2015-11-05 15:18:28
DEBUG设置为True吗?静态文件应用程序只在禁用调试模式时生成版本URL。
https://stackoverflow.com/questions/33529515
复制相似问题