프로젝트 생성
(myvenv) $ django-admin.py startproject mysite .
xdjangogirls
├───manage.py
└───mysite
settings.py
urls.py
wsgi.py
__init__.py
설정 변경
mysite/settings.py
을 코드 에디터로 열어서 설정을 변경한다.
시간대 변경
xxxxxxxxxx
TIME_ZONE = 'Asia/Seoul'
정적파일 경로 추가
xxxxxxxxxx
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
DEBUG
가 True
이고 ALLOWED_HOSTS
가 비어 있으면, 호스트는 ['localhost', '127.0.0.1', '[::1]']
에 대해서 유효한다. PythonAnywhere의 호스트 이름과 일치시키기 위해 설정을 아래와 같이 변경한다.
xxxxxxxxxx
ALLOWED_HOSTS = ['127.0.0.1', '.pythonanywhere.com']
데이터베이스 설정
장고에는 기본적으로 sqlite3
라는 데이터베이스가 설치되어 있다.
xxxxxxxxxx
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
데이터베이스를 생성하기 위해서 python manage.py migrate
명령을 실행시킨다.
xxxxxxxxxx
(myvenv) $ python manage.py migrate
Operations to perform:
Apply all migrations: auth, admin, contenttypes, sessions
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... 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 sessions.0001_initial... OK
python manage.py runserver
명령어를 실행해 웹 사이트가 작동하는지 확인한다.
xxxxxxxxxx
(myvenv) $ python manage.py runserver
'Python > Django' 카테고리의 다른 글
장고 걸즈 튜토리얼 따라하기 6 - 장고 urls (0) | 2018.12.24 |
---|---|
장고 걸즈 튜토리얼 따라하기 5 - 배포 (0) | 2018.12.23 |
장고 걸즈 튜토리얼 따라하기 4 - 장고 관리자 (0) | 2018.12.19 |
장고 걸즈 튜토리얼 따라하기 3 - 장고 model (0) | 2018.12.14 |
장고 걸즈 튜토리얼 따라하기 1 - 설치하기 (0) | 2018.12.10 |