上一页 1 2 3 4 5 6 ··· 39 下一页
摘要: 数据库结构和此文章相同:https://www.cnblogs.com/sch01ar/p/14295875.html urls.py: from django.urls import path, re_path from drf import views urlpatterns = [ path( 阅读全文
posted @ 2021-01-19 17:38 Sch01aR# 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 数据库结构和上篇文章一样:https://www.cnblogs.com/sch01ar/p/14295875.html views.py: from rest_framework.views import APIView from rest_framework import serializers 阅读全文
posted @ 2021-01-19 15:36 Sch01aR# 阅读(85) 评论(0) 推荐(0) 编辑
摘要: models.py: from django.db import models class UserGroup(models.Model): title = models.CharField(max_length=32) class UserInfo(models.Model): user_type 阅读全文
posted @ 2021-01-18 23:53 Sch01aR# 阅读(1125) 评论(0) 推荐(0) 编辑
摘要: model.py: from django.db import models class Role(models.Model): title = models.CharField(max_length=32) 在 role 表中创建数据 方法一:平常的方法 views.py: from drf im 阅读全文
posted @ 2021-01-18 20:40 Sch01aR# 阅读(98) 评论(0) 推荐(0) 编辑
摘要: https://www.cnblogs.com/sch01ar/p/11271914.html request.POST 的数据是从 request.body 中提取的,request.POST 有数据需要两个前提条件。 一,请求头中 Content-Type 的值为 application/x-w 阅读全文
posted @ 2021-01-18 16:47 Sch01aR# 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 自定义类实现: views.py: from django.shortcuts import HttpResponse from rest_framework.views import APIView from rest_framework.versioning import BaseVersion 阅读全文
posted @ 2021-01-18 15:47 Sch01aR# 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 在 app 目录下的 utils 目录下创建 throttle.py throttle.py: from rest_framework.throttling import SimpleRateThrottle import time # 访问记录 VISIT_RECORD = {} # 用于游客的访 阅读全文
posted @ 2021-01-17 23:32 Sch01aR# 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 在 app 目录下创建 utils 目录,并在该目录下创建 throttle.py throttle.py: from rest_framework.throttling import BaseThrottle import time # 访问记录 VISIT_RECORD = {} class M 阅读全文
posted @ 2021-01-17 15:41 Sch01aR# 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 在 app 目录下创建 utils 目录,并创建 auth.py 和 permission.py 文件 auth.py: from rest_framework.authentication import BaseAuthentication from drf import models from 阅读全文
posted @ 2021-01-16 14:33 Sch01aR# 阅读(111) 评论(0) 推荐(0) 编辑
摘要: views.py: from django.http import JsonResponse from rest_framework.views import APIView ORDER_DICT = { 1: { "commodity": "Phone", "price": 3600, "date 阅读全文
posted @ 2021-01-16 11:27 Sch01aR# 阅读(183) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 39 下一页