1. 파이썬 3버전 설치
파이썬 설치 링크 https://www.python.org/
2. 설치 후 장고 버전 확인
➜ chamchi python3 —version
python2 버전을 보완하여 python3 버전이 나왔고 앞으로 파이썬3만 사용될 것이므로 특별한 이유가 아니라면 python3 사용
3. pip3 업데이트
➜ chamchi pip3 install --upgrade pip
pip(Pip Installs Packages) : 파이썬 패키지 관리자
파이썬 설치 시 기본으로 설치되어 사용 전 최신버전으로 설치
4. 프로젝트 폴더 생성
실제 프로젝트 최상위 폴더 mkdir 리눅스 폴더 생성 명령어
➜ chamchi mkdir chamchi_tutorial
5. 가상환경 설치
➜ chamchi mkdir chamchi_tutorial
위에서 생성한 폴더에 접속 후
➜ chamchi mkdir chamchi_tutorial
➜ chamchi_tutorial pip3 install virtualenv
pip = python2
pip3 = python3
가상환경을 만드는 이유는 프로젝트간 충돌 방지
6. 가상환경 생성
➜ chamchi_tutorial virtualenv venv
venv는 가상환경명
출력
Already using interpreter /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 Using base prefix
'/Library/Frameworks/Python.framework/Versions/3.7' New python executable in
/Users/dongwon/project/study/chamchi_tutorial/venv/bin/python3.7 Also creating executable in
/Users/dongwon/project/study/chamchi_tutorial/venv/bin/python Installing setuptools, pip, wheel... done.
파이썬 버전을 지정해주려면
➜ chamchi_tutorial virtualenv --python=python3.7 venv
8. 가상환경 접속(가상환경 활성화 안되있을 시)
(venv) ➜ chamchi_tutorial source venv/bin/activate
(venv)이게 생겼다면 접속 성공
source 가상환경 실행 명령어
파이썬 패키지 관련한 모든 작업은 가상환경 접속 후 진행
가상환경 나가기
(venv) ➜ chamchi_tutorial deactivate
10. 장고 설치
(venv) ➜ chamchi_tutorial pip3 install django
pip가 아닌 pip3
출력
Collecting django Using cached
https://files.pythonhosted.org/packages/b2/79/df0ffea7bf1e02c073c2633702c90f4384645c40a1dd09a308e02ef0c817/Django-2.2.6-py3-none-any.whl Collecting pytz Using cached
https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl Collecting sqlparse Using cached
https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl Installing collected
packages: pytz, sqlparse, django Successfully installed django-2.2.6 pytz-2019.3 sqlparse-0.3.0
11. 장고 버전확인
(venv) ➜ chamchi_tutorial python3 -m django --version
출력 2.2.6
12. 장고 버전 업데이트
(venv) ➜ chamchi_tutorial pip3 install --upgrade django
13. 장고 프로젝트 생성
(venv) ➜ chamchi_tutorial django-admin startproject config .
django-admin django 명령어
startproject 프로젝트 생성 명령어
.은 현재 위치에 config 프로젝트를 만들라는 의미
확인
(venv) ➜ chamchi_tutorial ls -al
total 8
drwxr-xr-x 5 dongwon staff 160 11 1 14:53 .
drwxr-xr-x 6 dongwon staff 192 11 1 14:34 ..
drwxr-xr-x 6 dongwon staff 192 11 1 14:53 config
-rwxr-xr-x 1 dongwon staff 626 11 1 14:53 manage.py
drwxr-xr-x 6 dongwon staff 192 11 1 14:34 venv
14. 서버 실행, 테스트
(venv) ➜ chamchi_tutorial python3 manage.py runserver
서버를 실행하여 정상적으로 생성했는지 확인
출력
(venv) ➜ chamchi_tutorial python3 manage.py runserver Watching for file changes with StatReloader Performing system checks...
System check identified no issues (0 silenced).
You have 17 unapplied migration(s).
Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
November 01, 2019 - 05:54:38 Django version 2.2.6, using settings 'config.settings' Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
실행된 장고 접속 http://127.0.0.1:8000/
'파이썬 - python' 카테고리의 다른 글
파이썬 국내 슬랙 채널 (0) | 2020.05.24 |
---|---|
django nginx gunicorn 배포하기 / aws ec2 (0) | 2020.05.17 |
[장고] timezone 시간 맞추기 (0) | 2020.05.03 |
장고 환경 변수 분리 django Separating environment [.env / secrets.json] (0) | 2020.04.06 |
django Tailwind CSS Tutorial (0) | 2020.03.28 |