-
Django에서 WhiteNoise 사용하기Django 2019. 7. 11. 17:49
Django 에서 DEBUG = False 로 하게 되면
기존에 static 파일로 쓰던 것들이 모두 경로를 못찾게 된다.
그런때에 WhiteNoise 를 설치해 사용하면 해당 문제를 해결 할 수 있다.
WhiteNoise는 static파일들을 collectstatics 명령수행시 지정경로에 파일들을 모아주는 역할을 한다.
http://whitenoise.evans.io/en/stable/django.htmlUsing WhiteNoise with Django — WhiteNoise 4.1.2 documentation
This guide walks you through setting up a Django project with WhiteNoise. In most cases it shouldn’t take more than a couple of lines of configuration. I mention Heroku in a few places as that was the initial use case which prompted me to create WhiteNoise
whitenoise.evans.io
whitenoise 설치 방법
pip install whitenoise
settings.py 파일에서
미들웨어 부분 :
'whitenoise.middleware.WhiteNoiseMiddleware',
static_root 부분 :
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
'Django' 카테고리의 다른 글
Django ModelForm 에서 create, update 개발 (0) 2021.04.15 Django CharField 에서 ForeignKey 로 변경 (0) 2021.04.14 Django 각 일자별로 특정 필드 sum 하기 (0) 2020.06.16 Django template tag if 문에서 변수끼리 비교 (0) 2019.07.11 Mac에서 Django 와 MySql 연결하기 (0) 2016.11.22