pip install django-compressor python INSTALLED_APPS = ( ... 'compressor', ... ) STATICFILES_FINDERS = ( ... 'compressor.finders.CompressorFinder', ... ) COMPRESS_ENABLED = True COMPRESS_URL = STATIC_URL html {% load compress %} {% compress css %} <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'css/custom.css' %}"> {% endcompress %} html {% load compress %} {% compress js %} <script src="{% static 'js/main.js' %}"></script> <script src="{% static 'js/helper.js' %}"></script> {% endcompress %} html {% load compress %} {% compress html %} <p>This is some HTML content</p> {% endcompress %} python COMPRESS_PRECOMPILERS = ( ('text/css', 'compressor.filters.cssmin.rCSSMinFilter'), ('text/javascript', 'compressor.filters.jsmin.JSMinFilter'), ) python COMPRESS_CACHE_BACKEND = 'django.core.cache.backends.filebased.FileBasedCache' COMPRESS_CACHE_KEY_FUNCTION = 'compressor.cache.key_func'


上一篇:
下一篇:
切换中文