Search code examples
pythondjangoherokudjango-staticfiles

Why static files are served on Heroku without activating WhiteNoise?


I followed a tutorial on deploying Django app on Heroku server and I stumble across this:

  • I have installed WhiteNoise package for serving statics
  • Added inside settings.py:
MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware',
]

But omitted to activate it inside wsgi.py file:

from whitenoise import WhiteNoise
from my_project import MyWSGIApp
    application = MyWSGIApp()
    application = WhiteNoise(application, root='/path/to/static/files')
    application.add_files('/path/to/more/static/files', prefix='more-files/')

Why the static files are served on the production site ? Should not the above code be responsible for this ?


Solution

  • The wsgi.py integration hasn't been required since v3.0 and was removed in v4.0.