6-3. 프로젝트 기본구조 만들기
INFO
6-3-1. Pycharm 과 GitHub 연동
- GitHub > Code > Local Tap > HTTPS URL 복사한다.
그림6-3-1 GitHub Clone URL 복사
- 파이참 신규 프로젝트 생성한다.
그림6-3-2 파이참 신규 프로젝트 생성화면
- 파이참 > Get from VCS 선택 화면입니다.
그림6-3-3 파이참 GitHub 연결
그림6-3-4 프로젝트 디렉토리 설정
그림6-3-5 레포지토리 Sync 화면
그림6-3-6 파이참 프로젝트 생성 완료 화면
6-3-2. Pycharm 기본 프로젝트 만들기
- Virtual Envirment 설정
windows command
python --version
python -m venv venv
cd venv/Scripts
activate
(venv)
python -m django --version # 장고 설치 및 버전확인
python -m pip install django # 장고 설치 (신규 가상환경 생성시 장고 설치 필요함)
linux command
$/home/hyungsik74/pycharm/dstragram-project> python --version
$/home/hyungsik74/pycharm/dstragram-project> python -m venv venv
$/home/hyungsik74/pycharm/dstragram-project> source venv/bin/activate
(venv) $/home/hyungsik74/pycharm/dstragram-project>
(venv) $/home/hyungsik74/pycharm/dstragram-project> python -m django --version # 장고 설치 및 버전확인
(venv) $/home/hyungsik74/pycharm/dstragram-project> python -m pip install django # 장고 설치 (신규 가상환경 생성시 장고 설치 필요함)
(venv) PS C:\hyungsik74\pycharm\dstagram-project> python -m pip install django
Collecting django
Obtaining dependency information for django from https://files.pythonhosted.org/packages/bf/8b/c38f2354b6093d9ba310a14b43a830fdf776edd60c2e25c7c5f4d23cc243/Dja
ngo-4.2.5-py3-none-any.whl.metadata
Using cached Django-4.2.5-py3-none-any.whl.metadata (4.1 kB)
Collecting asgiref<4,>=3.6.0 (from django)
Obtaining dependency information for asgiref<4,>=3.6.0 from https://files.pythonhosted.org/packages/9b/80/b9051a4a07ad231558fcd8ffc89232711b4e618c15cb7a392a173
84bbeef/asgiref-3.7.2-py3-none-any.whl.metadata
Using cached asgiref-3.7.2-py3-none-any.whl.metadata (9.2 kB)
Collecting sqlparse>=0.3.1 (from django)
Using cached sqlparse-0.4.4-py3-none-any.whl (41 kB)
Collecting tzdata (from django)
Using cached tzdata-2023.3-py2.py3-none-any.whl (341 kB)
Using cached Django-4.2.5-py3-none-any.whl (8.0 MB)
Using cached asgiref-3.7.2-py3-none-any.whl (24 kB)
Installing collected packages: tzdata, sqlparse, asgiref, django
Successfully installed asgiref-3.7.2 django-4.2.5 sqlparse-0.4.4 tzdata-2023.3
(venv) PS C:\hyungsik74\pycharm\dstagram-project> python -m django --version
4.2.5
(venv) PS C:\hyungsik74\pycharm\dstagram-project>
(venv) PS C:\hyungsik74\pycharm\dstagram-project> python -m pip install django
Collecting django
Obtaining dependency information for django from https://files.pythonhosted.org/packages/bf/8b/c38f2354b6093d9ba310a14b43a830fdf776edd60c2e25c7c5f4d23cc243/Dja
ngo-4.2.5-py3-none-any.whl.metadata
Using cached Django-4.2.5-py3-none-any.whl.metadata (4.1 kB)
Collecting asgiref<4,>=3.6.0 (from django)
Obtaining dependency information for asgiref<4,>=3.6.0 from https://files.pythonhosted.org/packages/9b/80/b9051a4a07ad231558fcd8ffc89232711b4e618c15cb7a392a173
84bbeef/asgiref-3.7.2-py3-none-any.whl.metadata
Using cached asgiref-3.7.2-py3-none-any.whl.metadata (9.2 kB)
Collecting sqlparse>=0.3.1 (from django)
Using cached sqlparse-0.4.4-py3-none-any.whl (41 kB)
Collecting tzdata (from django)
Using cached tzdata-2023.3-py2.py3-none-any.whl (341 kB)
Using cached Django-4.2.5-py3-none-any.whl (8.0 MB)
Using cached asgiref-3.7.2-py3-none-any.whl (24 kB)
Installing collected packages: tzdata, sqlparse, asgiref, django
Successfully installed asgiref-3.7.2 django-4.2.5 sqlparse-0.4.4 tzdata-2023.3
(venv) PS C:\hyungsik74\pycharm\dstagram-project> python -m django --version
4.2.5
(venv) PS C:\hyungsik74\pycharm\dstagram-project>
그림6-3-2 venv 생성후 프로젝트 폴더 구조
- startproect 생성
- db migrate 생성
- admin id/password 생성
django-admin startproject config . python manage.py migrate python manage.py createsuperuser python manage.py runserver
windows command
django-admin startproject config .
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
linux command
venv) $/home/hyungsik74/pycharm/dstragram-project> django-admin startproject config .
venv) $/home/hyungsik74/pycharm/dstragram-project> python manage.py migrate
venv) $/home/hyungsik74/pycharm/dstragram-project> python manage.py createsuperuser
venv) $/home/hyungsik74/pycharm/dstragram-project> python manage.py runserver
(venv) PS C:\hyungsik74\pycharm\dstagram-project> django-admin startproject config .
(venv) PS C:\hyungsik74\pycharm\dstagram-project>
(venv) PS C:\hyungsik74\pycharm\dstagram-project> python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
(venv) PS C:\hyungsik74\pycharm\dstagram-project>
(venv) PS C:\hyungsik74\pycharm\dstagram-project> django-admin startproject config .
(venv) PS C:\hyungsik74\pycharm\dstagram-project>
(venv) PS C:\hyungsik74\pycharm\dstagram-project> python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
(venv) PS C:\hyungsik74\pycharm\dstagram-project>
그림6-3-2 프로젝트 생성 후 폴더 구조
그림6-3-2 관리자 아이디/암호 생성
그림6-3-2 기본 프로젝트 생성 후 프로젝트 실행 확인
그림6-3-2 사용자 페이지 접속 http://localhost:8000/
그림6-3-2 관리자 페이지 접속 http://localhost:8000/admin/
그림6-3-2 파이참 Run 버튼
그림6-3-2 파이참 Run 버튼
그림6-3-2 파이참 Run 설정
그림6-3-2 파이참 Run 메뉴
그림6-3-2 파이참 Run 실행