- 创建新项目
- django-admin startproject [项目名称]
- 创建新应用
- python manage.py startapp [app名称]
- django-admin startapp [APP名称]
- 检测模型变化,生成新的数据库迁移文件
- python manage.py makemigrations [app名称]
- 同步数据库与模型
- python manage.py migrate [app名称]
- 启动服务器
- python manage.py runserver
- # 默认端口8000 : python manage.py runserver
- # 指定IP和端口(不能局域网访问) : python manage.py runserver 127.0.0.1:8080
- # 指定IP和端口(局域网可访问): python manage.py runserver 192.168.0.0:8080
- # 指定端口: python manage.py runserver 8000
- 创建超级用户
- python manage.py createsuperuser
- 修改用户密码
- python manage.py changepassword username
- 打开交互终端
- python manage.py shell
- python manage.py dbshell(数据库交互)
- 查看当前版本
- python manage.py version
- 中文版设置
- LANGUAGE_CODE = 'zh-hans'
- TIME_ZONE = 'Asia/Shanghai'
- USE_I18N = True
- USE_L10N = True
- USE_TZ = False