티스토리 뷰

Django

DEBUG True / False 차이점

daylee de vel 2021. 7. 12. 13:52

Issue:
배포 연습 중 debug=False 로 셋업했더니 로컬호스트 주소에서 미디어 파일이 로딩되지 않음.
e.g. "GET /static/css/bootstrap.min.css HTTP/1.1" 404 179

Solution:
debug 모드를 켜면(==True) 에러의 디테일한 사항을 설명해준다. False의 상황에서는 ALLOWED_HOSTS 가 세팅되어야 있어야 하고, 미디어, 스태틱 파일의 엑세스가 제한된다. 즉 웹서버를 통해서 제공해야 함.

  • TheDEBUG=True, if there is error, page will show details of error.
  • ifDEBUG=False, theALLOWED_HOSTSofsettings.pywill work, you should take carefully to set it.
  • themediaandstaticwill not provide access forDEBUG=False, you have to provide them with the help of webserver, likeNginxorApache

출처: stackoverflow

댓글