官方网址:www.django-rest-framework.org/
1.创建虚拟环境,安装包
pip install django
pip install djangorestframework
pip install pymysql
pip install django-cors-headers // 它将CORS(跨源资源共享)头添加到响应中。
pip install django-safedelete // 安全删除,不是真的从数据库删除,而是屏蔽
2.创建项目
django-admin startproject myweb
cd myweb
python manage.py startapp App1
mkdir templates static
cd App1
touch urls.py serializers.py
3.修改配置文件





4.配置路由


5.定义模型

#生成迁移文件,迁移模型
python manage.py makemigrations
python manage.py migrate
1
6.创建视图


7.序列化






网友评论