接口
满心欢喜...
django mysql flank mongodb Linux
展开
-
过滤排序分页序列化
限流Throttling可以对接口访问的频次进行限制,以减轻服务器压力使用可以在配置文件中,使用DEFAULT_THROTTLE_CLASSES和DEFAULT_THROTTLE_RATES进行全局配置,# 限流配置REST_FRAMEWORK = { 'DEFAULT_THROTTLE_CLASSES':( 'rest_framework.throttling.AnonRateThrottle', 'rest_framework.throttling.Us原创 2020-10-28 17:25:29 · 136 阅读 · 0 评论 -
djangorestframework序列化
1. djangorestframework 序列化1.1序列化常用字段参数'''1. 选项参数'''name = serializers.CharField(min_length=3,max_length=20)max_length # 最大长度min_lenght # 最小长度allow_blank # 是否允许为空max_value # 最大值min_value # 最小值'''2. 通用参数'''gp = serializers.S原创 2020-10-12 20:24:15 · 249 阅读 · 0 评论 -
vue绑定用户页面
1.vue微博回调空页面1.vue微博回调空页面1.1 页面路径 components\oauth.vue<template> <div> <div v-show='visiable'> 绑定用户 用户名: <input type="text" v-model="username" @blur="check_username" > <span>{{原创 2020-10-09 20:00:09 · 122 阅读 · 0 评论 -
绑定微博用户接口
1.微博绑定用户接口1.微博绑定用户接口urlpatterns = [path(‘weibo/binduser/’, views.OauthWeiboBindUser.as_view()), # /oauth/weibo/callback/]1.2 oauth/views.py 中添加试图函数class OauthWeiboBindUser(APIView): permission_classes = (AllowAny,) def post(self,request):原创 2020-10-09 19:55:58 · 505 阅读 · 0 评论 -
绑定微博用户接口
vue微博回调空页面1.1 oauth/urls.py 中添加路由urlpatterns = [path(‘weibo/binduser/’,views.OauthWeiboBindUser.as_view()), # /oauth/weibo/callback/]1.2 oauth/views.py 中添加试图函数class OauthWeiboBindUser(APIView): permission_classes = (AllowAny,) def post(self,r原创 2020-10-09 19:46:37 · 180 阅读 · 0 评论 -
vue微博回调空页面
1.vue微博回调空页面注:微博回调空页面为: http://127.0.0.1:8888/oauth/callback/1.1 页面路径 components\oauth.vue<template> <div> <p>跳转中..<p> </div></template><script> import { oauth_callback_post, oauth_binduser_post,原创 2020-10-09 19:37:42 · 65 阅读 · 0 评论 -
微博回调接口
1.微博回调接口1.1 oauth/urls.py 中添加路由urlpatterns = [ path('weibo/callback/', views.OauthWeiboCallback.as_view()), # /oauth/weibo/callback/ ]1.2 oauth/views.py 中添加试图函数http://192.168.56.100:8888/oauth/weibo/callback/from .models import OauthUserfrom res原创 2020-10-09 19:19:52 · 104 阅读 · 0 评论 -
Vue获取微博授权url
1.在Vue页面加载时动态发送请求获取微博授 权url1.在Vue页面加载时动态发送请求获取微博授 权url1.1 在components\common\lab_header.vue中写oauth动态获取微博授权URL// 获取微博登录地址 oauth() { // 从后端获取 微博登录地址 oauth_post().then((resp) => { console.log(resp) //{'code': '0', 'msg': '成功', 'data': {'url':原创 2020-10-09 19:04:05 · 103 阅读 · 0 评论 -
生成微博授权url接口
1.创建apps/oauth模块进行oauth认证‘’‘2.1 在apps文件夹下新建应用: oauth’’’cd syl/appspython …/manage.py startapp oauth # 切换到apps文件夹下执行创建命令‘’‘2.2 添加子路由: oauth/urls.py’’’from django.urls import pathfrom . import viewsurlpatterns = []‘’‘2.3 在syl/settings.py中添加应用’’’INS原创 2020-10-09 18:50:20 · 404 阅读 · 0 评论 -
后端注册接口完善
1.完善注册接口1.1 修改user/views.py中完善视图函数# 注册接口class RegisterView(APIView): """ 用户注册, 权限是: 匿名用户可访问 """ # 自定义权限类 permission_classes = (AllowAny,) def post(self, request): """ 接收用户名,密码,手机号和验证码, 前端校验两遍一致性, 注册成功后返回成功, 然后用户自原创 2020-10-08 11:00:38 · 63 阅读 · 0 评论 -
图片验证码接口
1.django 缓存设置django的六种缓存(mysql+redis) :https://www.cnblogs.com/xiaonq/p/7978402.html#i61.1 安装Django缓存模块 pip install django-redis==4.12.11.2 syl/settings.py 中配置缓存#缓存配置 CACHES = { #django存缓默认位置,redis 0号库 #default: 连接名称 "default": { "BACKEND": "dja原创 2020-10-06 20:50:15 · 239 阅读 · 0 评论