Complete the code to import WhiteNoise middleware in Django settings.
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'[1]',
'django.contrib.sessions.middleware.SessionMiddleware',
]You add WhiteNoise by including 'whitenoise.middleware.WhiteNoiseMiddleware' in the MIDDLEWARE list.
Complete the code to set the static files storage to WhiteNoise's compressed manifest storage.
STATICFILES_STORAGE = '[1]'
WhiteNoise recommends using CompressedManifestStaticFilesStorage for better caching and compression.
Fix the error in the code to correctly wrap the Django WSGI application with WhiteNoise.
from django.core.wsgi import get_wsgi_application from whitenoise import WhiteNoise application = get_wsgi_application() application = [1](application, root='/path/to/static')
The WhiteNoise class wraps the WSGI application to serve static files.
Fill both blanks to configure WhiteNoise to add custom headers and enable max-age caching.
application = WhiteNoise(application, root='/static') application.add_headers('/static', [1]) application.max_age = [2]
WhiteNoise can add headers like Cache-Control for caching. max_age sets the cache duration in seconds.
Fill all three blanks to create a WhiteNoise middleware setup that compresses files, serves static files from 'staticfiles', and sets max-age to one day.
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
[1],
]
STATICFILES_STORAGE = [2]
application = get_wsgi_application()
application = WhiteNoise(application, root='[3]')
application.max_age = 86400This setup adds WhiteNoise middleware, uses compressed manifest storage, and serves static files from the 'staticfiles' directory with a one-day cache.