上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 30 下一页
摘要: jwt=Json Web token #原理 """ 1)jwt分三段式:头.体.签名 (head.payload.sgin) 2)头和体是可逆加密,让服务器可以反解出user对象;签名是不可逆加密,保证整个token的安全性的 3)头体签名三部分,都是采用json格式的字符串,进行加密,可逆加密一 阅读全文
posted @ 2022-04-08 01:47 咖喱给给啊 阅读(53) 评论(0) 推荐(0)
摘要: # 1 安装:pip install coreapi # 2 在路由中配置 from rest_framework.documentation import include_docs_urls urlpatterns = [ ... path('docs/', include_docs_urls(t 阅读全文
posted @ 2022-04-08 01:46 咖喱给给啊 阅读(35) 评论(0) 推荐(0)
摘要: # 写一个类,继承SimpleRateThrottle,只需要重写get_cache_key from rest_framework.throttling import ScopedRateThrottle,SimpleRateThrottle #继承SimpleRateThrottle class 阅读全文
posted @ 2022-04-08 01:45 咖喱给给啊 阅读(32) 评论(0) 推荐(0)
摘要: # 自定制频率类,需要写两个方法 -# 判断是否限次:没有限次可以请求True,限次了不可以请求False def allow_request(self, request, view): -# 限次后调用,显示还需等待多长时间才能再访问,返回等待的时间seconds def wait(self): 阅读全文
posted @ 2022-04-08 01:45 咖喱给给啊 阅读(23) 评论(0) 推荐(0)
摘要: # urls.py from django.urls import path,re_path from api import views urlpatterns = [ path('books/', views.BookAPIView.as_view()), re_path('books/(?P<p 阅读全文
posted @ 2022-04-08 01:43 咖喱给给啊 阅读(26) 评论(0) 推荐(0)
摘要: #views.py # 查所有,才需要分页 from rest_framework.generics import ListAPIView # 内置三种分页方式 from rest_framework.pagination import PageNumberPagination,LimitOffse 阅读全文
posted @ 2022-04-08 01:43 咖喱给给啊 阅读(21) 评论(0) 推荐(0)
摘要: class APIResponse(Response): def __init__(self,code=100,msg='成功',data=None,status=None,headers=None,**kwargs): dic = {'code': code, 'msg': msg} if dat 阅读全文
posted @ 2022-04-06 18:13 咖喱给给啊 阅读(49) 评论(0) 推荐(0)
摘要: 开启事务: start transaction; 开启事务后需要手动提交,没有提交的话数据库中表的数据不会发生变化, 虽然表里的数据没有变化,但是其实数据已经写入了,只是没有提交, BEGIN;UPDATE `test` SET `name` = "1"; 开始事务执行了这条sql,执行完毕后 数据 阅读全文
posted @ 2022-04-06 18:12 咖喱给给啊 阅读(35) 评论(0) 推荐(0)
摘要: #统一接口返回 # 自定义异常方法,替换掉全局 # 写一个方法 # 自定义异常处理的方法 from rest_framework.views import exception_handler from rest_framework.response import Response from rest 阅读全文
posted @ 2022-04-06 03:14 咖喱给给啊 阅读(38) 评论(0) 推荐(0)
摘要: from rest_framework.generics import ListAPIView from rest_framework.filters import OrderingFilter from app01.models import Book from app01.ser import 阅读全文
posted @ 2022-04-06 03:10 咖喱给给啊 阅读(9) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 30 下一页