Skip to content

Install from PyPI

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

Optional Extras

ServeStatic has optional extras (brotli and minify) for Brotli compression and minification. The example below shows how to install with these extras, but you can omit them if you don't need those features.

To install from PyPI, run the following command:

pip install servestatic[brotli, minify]

Using with ASGI

For configuration instructions, see the ASGI guide.

Using with WSGI

For configuration instructions, see the WSGI guide.

Using with Django

Below is the quick start guide for Django. For advanced configuration instructions, see the full Django guide.

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.

STORAGES = {
    "staticfiles": {
        "BACKEND": "servestatic.storage.CompressedManifestStaticFilesStorage",
    },
}