pip install django-compressor
python
INSTALLED_APPS = [
...
'compressor',
...
]
python
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
COMPRESS_ENABLED = True
COMPRESS_ROOT = STATIC_ROOT
python
{% load compress %}
python
{% compress css %}
<link rel="stylesheet" href="{% static 'css/main.css' %}">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
{% endcompress %}
{% compress js %}
<script src="{% static 'js/jquery.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
{% endcompress %}
python
{% compress css %}
...
{% endcompress %}
{% compress js cache %}
...
{% endcompress %}