pip install django-compressor
python
INSTALLED_APPS = [
...
'compressor',
]
python
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
python
COMPRESS_ENABLED = True
COMPRESS_CSS_FILTERS = [
'compressor.filters.cssdefault.CssAbsoluteFilter',
'compressor.filters.cssmin.CSSMinFilter',
]
COMPRESS_JS_FILTERS = [
'compressor.filters.jsmin.JSMinFilter',
]
COMPRESS_OUTPUT_DIR = 'compressed/'
html
{% load compress %}
{% compress css %}
<link rel="stylesheet" type="text/css" href="{% static 'path/to/your/css/file' %}">
{% endcompress %}
{% compress js %}
<script src="{% static 'path/to/your/js/file' %}"></script>
{% endcompress %}
css
@media (max-width: 768px) {
}