摘要:
models class Depart(models.Model): name = models.CharField(verbose_name='部门名', max_length=32) class UserInfo(models.Model): username = models.CharFiel 阅读全文
摘要:
默认解析器 JSONParser, FormParser, MultiPartParser view class UserView(OrPermissionAPIView): from rest_framework.parsers import JSONParser, FormParser from 阅读全文
摘要:
路由 urlpatterns = [ path('api/user/', views.UserView.as_view(),name='user'), ] view class UserView(OrPermissionAPIView): def get(self, request, *args, 阅读全文
摘要:
路由 urlpatterns = [ path('api/<str:version>/user/', views.UserView.as_view(),name='user'), ] settings REST_FRAMEWORK = { # 版本配置 "DEFAULT_VERSIONING_CLA 阅读全文
摘要:
视图 from rest_framework.versioning import QueryParameterVersioning class OrderView(OrPermissionAPIView): versioning_class = QueryParameterVersioning de 阅读全文
摘要:
重写SimpleRateThrottle的get_cache_key from rest_framework.throttling import SimpleRateThrottle from django.core.cache import cache as default_cache class 阅读全文
摘要:
原权限判断代码 def check_permissions(self, request): """ Check if the request should be permitted. Raises an appropriate exception if the request is not perm 阅读全文
摘要:
组件类(返回True为通过) from rest_framework.permissions import BasePermission class DemoPermission(BasePermission): # 自定义失败的返回信息 message = {"status": False, 'c 阅读全文
摘要:
建表 from django.db import models class UserInfo(models.Model): username = models.CharField(verbose_name='用户名', max_length=32) password = models.CharFie 阅读全文
摘要:
class BaseAuthentication: """ All authentication classes should extend BaseAuthentication. """ def authenticate(self, request): """ 如果子类继承BaseAuthenti 阅读全文