上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
摘要: models class Depart(models.Model): name = models.CharField(verbose_name='部门名', max_length=32) class UserInfo(models.Model): username = models.CharFiel 阅读全文
posted @ 2022-10-04 09:19 Sherwin_szw 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 默认解析器 JSONParser, FormParser, MultiPartParser view class UserView(OrPermissionAPIView): from rest_framework.parsers import JSONParser, FormParser from 阅读全文
posted @ 2022-10-03 16:57 Sherwin_szw 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 路由 urlpatterns = [ path('api/user/', views.UserView.as_view(),name='user'), ] view class UserView(OrPermissionAPIView): def get(self, request, *args, 阅读全文
posted @ 2022-10-03 15:15 Sherwin_szw 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 路由 urlpatterns = [ path('api/<str:version>/user/', views.UserView.as_view(),name='user'), ] settings REST_FRAMEWORK = { # 版本配置 "DEFAULT_VERSIONING_CLA 阅读全文
posted @ 2022-10-03 14:53 Sherwin_szw 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 视图 from rest_framework.versioning import QueryParameterVersioning class OrderView(OrPermissionAPIView): versioning_class = QueryParameterVersioning de 阅读全文
posted @ 2022-10-02 18:01 Sherwin_szw 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 重写SimpleRateThrottle的get_cache_key from rest_framework.throttling import SimpleRateThrottle from django.core.cache import cache as default_cache class 阅读全文
posted @ 2022-10-02 11:43 Sherwin_szw 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 原权限判断代码 def check_permissions(self, request): """ Check if the request should be permitted. Raises an appropriate exception if the request is not perm 阅读全文
posted @ 2022-10-01 18:56 Sherwin_szw 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 组件类(返回True为通过) from rest_framework.permissions import BasePermission class DemoPermission(BasePermission): # 自定义失败的返回信息 message = {"status": False, 'c 阅读全文
posted @ 2022-10-01 16:47 Sherwin_szw 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 建表 from django.db import models class UserInfo(models.Model): username = models.CharField(verbose_name='用户名', max_length=32) password = models.CharFie 阅读全文
posted @ 2022-10-01 10:42 Sherwin_szw 阅读(22) 评论(0) 推荐(0) 编辑
摘要: class BaseAuthentication: """ All authentication classes should extend BaseAuthentication. """ def authenticate(self, request): """ 如果子类继承BaseAuthenti 阅读全文
posted @ 2022-10-01 08:35 Sherwin_szw 阅读(25) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页