Django’s static files belong to a release. Uploaded media belongs to users and may outlive many releases. A good CDN deployment keeps those lifecycles separate, even when some of the public files ultimately use the same delivery network.

Trace one static reference

Copy a stylesheet URL from the rendered HTML. After collectstatic runs, check that its file exists in the release output and that the origin serves it at the path in the URL. If the file is present locally and returns 404 through the origin, compare the deployed directory with the STATIC_URL prefix before investigating the CDN.

Collect files as part of a configured build
python manage.py collectstatic --noinput

Deploy a complete, matching release

If you use manifest-based hashed names, publish the generated manifest and files as a compatible set. Probe the admin stylesheet and a file referenced inside application CSS. Keep previous release files available while workers, cached pages and open browser sessions may still reference them.

Decide who can read each upload

A shop’s public product photo and a user’s uploaded identity document need different handling. Leave private uploads behind authorization, protect the original file and prevent shared caching where required. When public uploads can be replaced in place, use shorter freshness or assign a new name on replacement.

Sources & further reading

Reader questions

Does collectstatic gather files from MEDIA_ROOT?

User uploads follow the application’s media storage lifecycle. The staticfiles deployment gathers configured application assets. Migrate and protect media separately.