ウェイトレスでホワイトノイズを使用して静的ファイルを提供していますが、バージョン管理された静的ファイルを使用することができませんでした。たとえば、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.
ここに私の 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>
そして、ウェイトレス サーバーを次のように実行します。
waitress-serve --port=8080 --call myapp.wsgi:white
ページをロードすると、ブラウザにこれが表示されることを期待しています
<script src="/static/foo.10a400e06df8.js" type="text/javascript"></script>
しかし、私はまだ見ています
<script src="/static/foo.js" type="text/javascript"></script>
私は何かを逃しましたか?私の設定では、STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' があります。
どんな助けや提案も大歓迎です!