It compresses css / js. The cache is generated when the page is accessed. If DEBUG = True is specified in settings.py, it will not be compressed.
1 Install with pip
python
$ pip install django-css
2 Edit settings.py
python
# MEDIA_ROOT、MEDIA_Make sure the URL is set up properly
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'www')
MEDIA_URL = '/www/'
INSTALLED_APPS = (
# 'compressor'Add
'compressor',
)
python
{% load compress %}
{% compress css %}
<link rel="stylesheet" href="/media/css/one.css" type="text/css" charset="utf-8">
<link rel="stylesheet" href="/media/css/two.sass" type="text/css" charset="utf-8">
{% endcompress %}
{% load compress %}
{% compress js %}
<script src="/media/js/one.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">obj.value = "value";</script>
{% endcompress %}
python
<link rel="stylesheet" href="/media/CACHE/css/f7c661b7a124.css" type="text/css" media="all" charset="utf-8">
<script type="text/javascript" src="/media/CACHE/js/3f33b9146e12.js" charset="utf-8"></script>
Package Index django-css 2.3.1
Recommended Posts