创建项目
django-admin startproject mysite
创建应用
python manage.py startapp appname
数据库迁移
python manage.py migrate
制作迁移
python manage.py makemigrations appname
创造超级管理员账户
python manage.py createsuperuser
常用的model field
CharField FloatField IntegerField TextField
常用的两个response
from django.http import HttpResponse,JsonResponse
数据库插入数据示例
>>> from blog.models import Blog
>>> b = Blog(name=’Beatles Blog’, tagline=’All the latest Beatles news.’)
>>> b.save()
数据库查询所有数据示例
all_entries = Entry.objects.all()
使用filter设置简单的条件
Entry.objects.filter(pub_date__year=2006)
廖🐺?