Quick Start
The documentation below is a quick-start guide to using ServeStatic
to serve your static files. For more detailed information see the full installation docs.
Installation¶
Install with:
pip install servestatic
Using with Django¶
Edit your settings.py
file and add ServeStatic
to the MIDDLEWARE
list, above all other middleware apart from Django's SecurityMiddleware.
MIDDLEWARE = [
# ...
"django.middleware.security.SecurityMiddleware",
"servestatic.middleware.ServeStaticMiddleware",
# ...
]
That's it, you're ready to go.
Want forever-cacheable files and compression support? Just add this to your settings.py
.
STATICFILES_STORAGE = "servestatic.storage.CompressedManifestStaticFilesStorage"
For more details, including on setting up CloudFront and other CDNs see the full Django guide.
Using with WSGI¶
To enable ServeStatic
you need to wrap your existing WSGI application in a ServeStatic
instance and tell it where to find your static files. For example...
1 2 3 4 5 6 7 |
|
And that's it, you're ready to go. For more details see the full WSGI guide.
Using with ASGI¶
To enable ServeStatic
you need to wrap your existing ASGI application in a ServeStatic
instance and tell it where to find your static files. For example...
1 2 3 4 5 6 7 |
|
And that's it, you're ready to go. For more details see the full ASGI guide.