1、安装Django2.2
pip install Django==2.2
2、创建项目
django-admin startproject helloworld
3、创建应用
django-admin startapp app
4、项目配置
# 允许访问的主机列表
ALLOWED_HOSTS = ['*']
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app' # 已安装的应用
]
# 中文
LANGUAGE_CODE = 'zh-hans'
# 时区
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
# 不使用UTC时间
USE_TZ = False
5、启动
python .\manage.py runserver 8001
python .\manage.py runserver 127.0.0.1:8001