上一页 1 ··· 8 9 10 11 12 13 14 下一页
摘要: throttle(访问频率)组件 1.局部视图throttle from rest_framework.throttling import BaseThrottle VISIT_RECORD={} class VisitThrottle(BaseThrottle): def __init__(sel 阅读全文
posted @ 2018-10-07 13:38 G先生 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 权限组件 写在开头: 首先要在models表中添加一个用户类型的字段: class User(models.Model): name=models.CharField(max_length=32) pwd=models.CharField(max_length=32) type_choice=((1 阅读全文
posted @ 2018-10-07 12:13 G先生 阅读(440) 评论(0) 推荐(0) 编辑
摘要: 1. CBV: pass 2 .APIView class BookView(APIView):pass url(r'^books/$', views.BookView.as_view(),name="books"), url(r'^books/$', View类下的view,name="books 阅读全文
posted @ 2018-10-07 11:21 G先生 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 认证组件 1.登录认证(与组件无关): 首先要在model表内添加用户表和token表: from django.db import models # Create your models here. class User(models.Model): name=models.CharField(m 阅读全文
posted @ 2018-10-06 18:42 G先生 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 视图三部曲 第一种方式: 使用混合(mixins): serialize.py class AuthorModelSerializers(serializers.ModelSerializer): class Meta: model = Author fields = "__all__" urls. 阅读全文
posted @ 2018-10-06 14:14 G先生 阅读(221) 评论(0) 推荐(0) 编辑
摘要: hasattr(obj,name): 判断一个对象里面是否有name属性或者name方法,返回BOOL值,有name特性返回True, 否则返回False。需要注意的是name要用括号括起来 1 >>> class test(): 2 ... name="xiaohua" 3 ... def run 阅读全文
posted @ 2018-10-06 12:06 G先生 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 快速实例 Quickstart 序列化 开篇介绍: 一切皆是资源,操作只是请求方式 book表增删改查 /books/ books /books/add/ addbook /books/(\d+)/change/ changebook /books/(\d+)/delete/ delbook boo 阅读全文
posted @ 2018-10-05 15:33 G先生 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 什么是RESTful 一种软件架构风格、设计风格,而不是标准,只是提供了一组设计原则和约束条件。它主要用于客户端和服务器交互类的软件。基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制。 一、URI规范 1.不用大写; 2.用中杠 - 不用下杠 _ ; 3.参数列表要encode; 4 阅读全文
posted @ 2018-10-05 14:52 G先生 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 一、http请求 1.Http请求格式 Http请求即客户端发送给服务器的请求。该请求的内容格式如下所示: 请求首行 请求头信息 空行 请求正文,也称请求体 2.使用HttpWatch抓包工具 请求信息详细内容如下: GET /Example03/ HTTP/1.1 Accept: image/jp 阅读全文
posted @ 2018-10-04 16:31 G先生 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 阅读目录 1、引入权限组件rbac 2、分配权限 3、登录、引入中间件 1、引入权限组件rbac 1、settings配置app、中间件 INSTALLED_APPS = [ ... ... 'crm.apps.CrmConfig', "stark.apps.StarkConfig", 'rbac. 阅读全文
posted @ 2018-10-04 11:34 G先生 阅读(220) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 下一页

:guocheng