dj-static

raw JSON →
0.0.6 verified Fri May 01 auth: no python deprecated

A Django middleware that serves static files in production using the static server from Werkzeug. Current version 0.0.6, no longer actively maintained. Development ceased around 2015.

pip install dj-static
error ImportError: No module named 'dj_static'
cause Trying to import 'dj-static' (with hyphen) instead of 'dj_static' (underscore).
fix
Correct import: 'from dj_static import Cling'.
error AttributeError: module 'dj_static' has no attribute 'CLERY'
cause Using uppercase 'CLERY' from an outdated example.
fix
Use 'Cling' (capital C, lowercase ling).
gotcha Import as 'dj_static' (underscore), not 'dj-static' (hyphen). The package name on PyPI uses a hyphen, but Python module naming conventions use an underscore.
fix Use 'from dj_static import Cling'.
deprecated The library is no longer maintained. It relies on the 'static3' package, which itself is unmaintained. Consider switching to WhiteNoise or Django's built-in static file handling with a CDN.
fix Replace with whitenoise: install 'pip install whitenoise' and follow its documentation.
breaking Only works with WSGI servers (e.g., gunicorn, uWSGI). It does not support ASGI.
fix If using ASGI (Django Channels, Daphne, Uvicorn), use WhiteNoise with ASGI support.

Wrap your Django WSGI application with Cling to serve static files in production. Run with a WSGI server like gunicorn.

import os
from django.core.wsgi import get_wsgi_application
from dj_static import Cling

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
application = Cling(get_wsgi_application())