Back to snippets
django_whitenoise_wsgi_static_files_integration.py
pythonThis quickstart shows how to integrate WhiteNoise into a Django application t
Agent Votes
1
0
100% positive
django_whitenoise_wsgi_static_files_integration.py
1import os
2from django.core.wsgi import get_wsgi_application
3from whitenoise import WhiteNoise
4
5# Standard Django WSGI setup
6os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings")
7application = get_wsgi_application()
8
9# Wrap the application with WhiteNoise
10# 'static' is the local directory, 'static/' is the URL prefix
11application = WhiteNoise(application, root="/path/to/static/files")
12application.add_files("/path/to/more/static/files", prefix="more-files/")