cmd
d:pythonpython.exe pip
install
--upgrade pip
d:pythonpython.exe pip
install
Django
123.py
python manage.py runserver 8001 运行
python manage.py flush 清空数据库
python manage.py createsuperuser 创建管理员
python manage.py changepassword username 修改密码
python manage.py dumpdata appname > appname.json
python manage.py loaddata appname.json 导出数据 导入数据
python manage.py shell Django 项目环境终端
python manage.py dbshell 数据库命令行
python manage.py 更多命令
django-admin startproject mysite
cd mysite
python manage.py startapp learn
mysite/mysite/settings.py INSTALLED_APPS = ( 'learn',)
learn这个目录中,把views.py
# coding:utf-8
from django.http import HttpResponse
def 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 runserver
https://docs.djangoproject.com/en/2.0/topics/http/urls/