Project 생성
새로운 Django 기초 강의를 하나 더 듣기 시작했다.
전에는 pycharm IDE를 사용했지만 이번에는 VSCode를 쓴다.
폴더 생성 후, git bash에서 가상환경(별도의 python 공간)을 만들어 준다.
python -m venv venv
가상환경을 켜준다.
source venv/Scripts/activate
* pip list: 가상환경에 설치된 파일들 list 볼 때
deactivate: 가상환경 끌 때
project 마다 venv를 각각 관리
Github 연결
git 사용을 하기 위해 git bash에 command를 입력한다.
git init
*ls: 현재 위치에서의 파일들 보기
ls -a: 현재 위치에서의 모든 파일들 보기
rm -rf .git: .git file 삭제
'.gitignore'이라는 파일을 생성
gitignore.io => Windows, macOS, visualstudioCode, python, Django 검색 => 생성 된 내용을 복사해서 파일에 넣어준다
github에서 new project 생성 후, ssh 주소 복사
git remote add origin ssh주소
*만약, git branch name이 'master'로 되어 있다면, 아래의 command로 main으로 바꿔주기
git branch -m master main
git config --global init.defaultBranch main
git add .
git commit -m '(massage 입력)'
git push origin main
* git log: 저장한 기록 보기
*다른 팀원이 github에 있는 folder 받아올 때
git clone ssh주소
팀원과 버전 정보 공유
Django download 받고,
pip install django
README.md file도 작성하고,
다른 팀원과 version을 공유할 때
pip freeze > requirements.txt
*code . :하면 vscode를 켤 수 있음
안되면, crtl + shift + p => 'Shell command: install 'code' command in PATH ' 클릭
*다른 팀원이 requirements.txt에 있는 버전대로 installation 할 때 command:
pip install -r requirements.txt
*extension program 중, 'Thunder Client' download.(Postman으로 해도 됨)
Django Project 생성
django-admin startproject firstproject .
뒤에 . 붙이면 현재 위치에 폴더 설치
*project 제거
rm -rf project name
Django project 실행
python manage.py runserver
Database를 사용할 때 command
python manage.py makemigrations
python manage.py migrate
Admin 계정 만들 때 command
python manage.py createsuperuser
기능 별로 app 만들 때 command
python manage.py startapp <app 이름>
'Computer Programming > AI' 카테고리의 다른 글
TIL_Django Project 중 Cookie와 Session 정리 (1) | 2023.09.04 |
---|---|
WIL_네 번째 주 (0) | 2023.09.03 |
TIL_Django로 Project 만들기 (0) | 2023.08.31 |
TIL_Python의 framework, Django (0) | 2023.08.30 |
TIL_Django 시작 (1) | 2023.08.29 |