docs: add web asset management category intro

The page had no intro, so readers got no pick between django-storages and Django Compressor.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-09-27 06:26:25 +08:00
co-authored by Claude
parent d7c709371f
commit 8b04838903
@@ -0,0 +1,12 @@
Django serves static files only in development, but django-storages puts them and user uploads on S3 or other clouds. Django Compressor bundles CSS and JS.
How to choose:
- Static files and user uploads on S3, Google Cloud Storage, or Azure: django-storages
- CSS and JavaScript combined and minified from your templates: Django Compressor
django-storages is [a collection of storage backends for Django](https://django-storages.readthedocs.io/en/latest/): Amazon S3, Google Cloud Storage, Azure Storage, and more. Install the extra for your backend, like [`django-storages[s3]`](https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#installation). Configure it through Django's [`STORAGES` setting](https://docs.djangoproject.com/en/stable/ref/settings/#storages), with the backend's settings under `OPTIONS`. The `default` key stores user uploads, and a `staticfiles` key has `collectstatic` [put your static files on S3](https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#configuration-settings) too. Django's security docs say to [serve user uploads from a separate domain](https://docs.djangoproject.com/en/stable/topics/security/#user-uploaded-content), not a subdomain of your site.
Django Compressor [processes, combines, and minifies](https://github.com/django-compressor/django-compressor) the CSS and JavaScript in your Django templates into cacheable static files. It also supports compilers like Sass and LESS. Its maintainer sees it as [an alternative for people who don't want to keep up](https://github.com/django-compressor/django-compressor/discussions/1095) with JavaScript build tools and want one easy setup for development and production. Add `compressor` to `INSTALLED_APPS` and [its finder](https://django-compressor.readthedocs.io/en/stable/quickstart.html) to `STATICFILES_FINDERS`. Then wrap your `<link>` and `<script>` tags in `{% compress css %}` and `{% compress js %}` blocks. In production, its docs [strongly recommend a real cache backend](https://django-compressor.readthedocs.io/en/stable/usage.html). On several servers, or with compressed files on a CDN, use [offline compression](https://django-compressor.readthedocs.io/en/stable/scenarios.html#offline-compression): set `COMPRESS_OFFLINE` and run `manage.py compress` when you deploy. Jinja2 templates work through [its extension](https://django-compressor.readthedocs.io/en/stable/jinja2.html).
django-storages and Django Compressor work together. Django Compressor's docs [point to django-storages](https://django-compressor.readthedocs.io/en/stable/remote-storages.html#django-storages) for pushing compressed files to S3, and it saves them to the storage you define under [the `compressor` alias](https://django-compressor.readthedocs.io/en/stable/settings.html#django.conf.settings.COMPRESS_STORAGE_ALIAS) in `STORAGES`.