프로그래밍/Python & dJango

[dJango] compressor

bbuljj 2016. 10. 3. 15:40

1. compressor js , css 파일등을 압축할 때 사용되며, js나 css 파일들이 간혹 브라우저 캐시로 인해서


   갱신 되지 않는 경우가 있는데 compressor를 사용하면  이러한 부분들도 해결된다.


2. 설치

   1) 아래 명령어 실행



$ pip install django_compressor


   2) setting.py 수정



INSTALLED_APPS = [
...,
...,
'compressor',
]


STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)

COMPRESS_ENABLED = True



 3. 사용법

{% compress js %}
<script src="{% static 'js/test.js' %}"></script>
{% endcompress %}


4. 결과