cmd
d:\python\python.exe pip
install
--upgrade pip
d:\python\python.exe pip
install
Django
123.py
import django
print(django.VERSION)
print(django.get_version())
cmd
django-admin.py startproject project_name 当前 目录建一个模板
python manage.py startapp flm 创建一个APP项目
python manage.py makemigrations 创建一个迁移文件
python manage.py migrate 迁移
python manage.py runserver 8001 运行
python manage.py flush 清空数据库python manage.py createsuperuser 创建管理员python manage.py changepassword username 修改密码python manage.py dumpdata appname > appname.jsonpython manage.py loaddata appname.json 导出数据 导入数据python manage.py shell Django 项目环境终端python manage.py dbshell 数据库命令行python manage.py 更多命令
django-admin startproject mysite
cd mysitepython manage.py startapp learn mysite/mysite/settings.py INSTALLED_APPS = ( 'learn',)learn这个目录中,把views.py# coding:utf-8from django.http import HttpResponsedef index(request): return HttpResponse(u"欢迎光临 自强学堂!")mysite/mysite/urls.py
from learn import views as learn_views # new
urlpatterns = [ path('', learn_views.index), # new] python manage.py runserverhttps://docs.djangoproject.com/en/2.0/topics/http/urls/