$ pip install django-compressor
python
# settings.py
INSTALLED_APPS = [
...
'compressor',
]
...
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
COMPRESS_ENABLED = True
html
<!-- index.html -->
{% load compress %}
{% compress css %}
<link rel="stylesheet" href="/static/css/style1.css">
<link rel="stylesheet" href="/static/css/style2.css">
{% endcompress %}
{% compress js %}
<script src="/static/js/script1.js"></script>
<script src="/static/js/script2.js"></script>
{% endcompress %}