[dJango] compressor

2016. 10. 3. 15:40프로그래밍/Python & dJango

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. 결과


'프로그래밍 > Python & dJango' 카테고리의 다른 글

Python 환경변수 가져오기.  (0) 2016.10.05
[Python] map, filter, reduce  (0) 2016.10.04
[Python] with 구문  (0) 2016.09.30
[django] template tag "with" 사용법  (0) 2016.09.30
[Python] 문자열 자르기 (slice)  (0) 2016.09.28