https://docs.djangoproject.com/ko/5.0/intro/tutorial02/
첫 번째 장고 앱 작성하기, part 2 | Django 문서
The web framework for perfectionists with deadlines.
docs.djangoproject.com
데이터베이스의 테이블을 생성하기 위해 다음의 migrate 명령으로 INSTALL_APPS의 설정을 탐색하여 데이터베이스의 테이블을 생성한다고 한다.
그 전에 TIME_ZONE 설정으로 한국의 시간을 맞추기 위해 TIME_ZONE = 'Asia/Seoul' 로 변경해준다.
py manage.py migrate
Django에서 데이터베이스 테이블을 생성 후 테이블의 스키마를 보고 싶다면 다음과 같은 명령으로 확인할 수 있다.
일반적으로 잘 만들어졌다는 내용이 나오겠지만, 테이블을 확인하고 싶을 수 있으니 홈페이지에 없는 내용을 추가로 작성한다.
python manage.py dbshell
.tables
.schema your_table_name

migrate 명령으로 생성된 테이블 중 django_admin_log와 django_session의 테이블의 스키마를 확인한 결과이다.
+------------------+--------------------+----------------------------------------------------+
| Column Name | Data Type | Constraints |
+------------------+--------------------+----------------------------------------------------+
| id | integer | PRIMARY KEY AUTOINCREMENT |
| object_id | text | NULL |
| object_repr | varchar(200) | NOT NULL |
| action_flag | smallint unsigned | NOT NULL CHECK (action_flag >= 0) |
| change_message | text | NOT NULL |
| content_type_id | integer | NULL REFERENCES django_content_type(id) |
| | | DEFERRABLE INITIALLY DEFERRED |
| user_id | integer | NOT NULL REFERENCES auth_user(id) |
| | | DEFERRABLE INITIALLY DEFERRED |
| action_time | datetime | NOT NULL |
+------------------+--------------------+----------------------------------------------------+
django_admin_log 테이블 구조를 시각적으로 표현
+----------------+----------------+---------------+
| Column Name | Data Type | Constraints |
+----------------+----------------+---------------+
| session_key | varchar(40) | PRIMARY KEY |
| session_data | text | NOT NULL |
| expire_date | datetime | NOT NULL |
+----------------+----------------+---------------+
django_session 테이블 구조를 시각적으로 표현
관리자 생성 시, 비밀번호를 1234 혹은 1q2w3e4r 으로 입력하게 되면 이렇게 생성할거냐고 묻는데, y를 선택하면 생성이 되기는 한다.
여기서 생성한 비번이 계정의 비밀번호가 되므로 잊지 않게 설정하자

다음으로
[Django] 4. Django 앱 작성하기 part.3 (View 확인하기)
https://docs.djangoproject.com/ko/5.0/intro/tutorial03/ 첫 번째 장고 앱 작성하기, part 3 | Django 문서The web framework for perfectionists with deadlines.docs.djangoproject.com 뷰 추가하기를 따라서 각각의 뷰를 추가하고나서
haku-s.tistory.com
'Python > Django' 카테고리의 다른 글
| [Django] 6. Django 앱 작성하기 part.5 (Unit Test) (0) | 2024.07.22 |
|---|---|
| [Django] 5. Django 앱 작성하기 part.4 (Vote & Results page) (0) | 2024.07.21 |
| [Django] 4. Django 앱 작성하기 part.3 (View 확인하기) (0) | 2024.07.21 |
| [Django] 2. Django 앱 작성하기 part.1 (CommandNotFoundException) (0) | 2024.07.17 |
| [Django] 1. 설치 Django Document 따라하기 (ModuleNotFoundError: No module namded 'django') (0) | 2024.07.17 |