Django7- Django Shell

Django Shell

박건령
박건령
Sep 9, 2018 · 2 min read
  • 장고 프로젝트 설정이 로딩된 파이썬 쉘
shell> python manage.py shell
  • 장고 프로젝트 설정이 로딩되지 않아,
  • 일반 파이썬 쉘로는 장고 환경에 접근 불가
  • ipython이 설치되어있다면, ipython으로 쉘을 구동
#ipython 설치명령(jupyter notebook까지 같이 설치)
shell> pip install "ipython[notebook]"

Jupyter Notebook으로 Django Shell 띄우기

django-extensions 설치

shell> pip install django-extensions

django extensions는 django app구조로 되어있다.

따라서, settings.py 내 INSTALLED_APPS에 “django_extensions”를 추가해줘야 한다.

#실행 명령shell> python manage.py shell_plus --notebook

jupyter 노트북에서 shell_plus를 사용하면

  • 장고 프로젝트를 모두 로딩해준다.
  • 친숙한 ui를 사용할 수 있다.
  • 사용한 명령들을 로그 형식으로 남긴다.
  • shell에서는 볼 수 없는 실행결과에서의 이미지 파일을 출력할 수 있다.
    박건령

    Written by

    박건령

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade