Notice
Recent Posts
Recent Comments
관리 메뉴

안까먹을라고 쓰는 블로그

[Python_Django_VSCode] Django Tutorials - 11 (collectstatic 명령 사용) 본문

Language/Python(Django)

[Python_Django_VSCode] Django Tutorials - 11 (collectstatic 명령 사용)

YawnsDuzin 2022. 1. 19. 14:56

 

반응형


https://code.visualstudio.com/docs/python/tutorial-django

 

Python and Django tutorial in Visual Studio Code

Python Django tutorial demonstrating IntelliSense, code navigation, and debugging for both code and templates in Visual Studio Code, the best Python IDE.

code.visualstudio.com


collectstatic 명령 사용


프로덕션 배포의 경우 일반적으로 python manage.py collectstatic 명령을 사용하여 앱의 모든 정적 파일을 단일 폴더로 수집합니다. 그런 다음 전용 정적 파일 서버를 사용하여 해당 파일을 제공할 수 있습니다. 그러면 일반적으로 전반적인 성능이 향상됩니다. 다음 단계는 Django 개발 서버와 함께 실행할 때 컬렉션을 사용하지 않지만 이 컬렉션이 어떻게 만들어지는지 보여줍니다.

1. web_project/settings.py 에서 collectstatic 명령을 사용할 때 정적 파일이 수집되는 위치를 정의하는 다음 줄을 추가합니다.

STATIC_ROOT = BASE_DIR / 'static_collected'


2. 터미널에서 python manage.py collectstatic 명령을 실행하고 hello/site.cssmanage.py 와 함께 최상위 static_collected 폴더에 복사되는지 확인합니다.

static_collected 폴더가 자동으로 생성이 되고, 그안에 파일들이 수집된다.


3. 실제로는 정적 파일을 변경할 때마다 그리고 프로덕션에 배포하기 전에 collectstatic을 실행하십시오.


끝~

반응형
Comments