I am using whitenoise with waitress to serve my static files, but I could not get it to use the versioned static file. For example, if I have a foo.js, after I run collectstatic, whitenoise creates the following files in my static folder:
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:
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:
{% 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
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'
Any help or suggestions is highly appreciated!
Is DEBUG
set to True
? The staticfiles app only generates versioned URLs when debug mode is disabled.