manmanrai’s diary

勉強記録ブログ

Django tutorial かき集め-1

Django

Python Web Framework
Model Template View

Environment

Python 3.7

Virtual Environment Setup

$ mkdir first-django
$ cd first-django
$ python3 -m venv myvenv   

Django installation

$ pip3 install django==1.11   

Create Django Project

$ django-admin startproject myapp .

Change Time Zone

$ cd myapp
$ vi ./settings.py

setting.py

LANGUAGE_CODE = 'ja'
TIME_ZONE = 'Asia/Tokyo'
USE_TZ = False

Database setting

Use default SQLite

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

Migrate

$ python manage.py migrate

Run Server

$ python3 manage.py runserver

Check it on the browser

default IP address and port

http://127.0.0.1:8000/

Create A Application

$ python3 manage.py startapp blog
myvenv
├── bin
├── blog
├── db.sqlite3
├── include
├── lib
├── manage.py
├── myapp
└── pyvenv.cfg