摘要: #优化cbc就代码其它post put delete方法,同理 class BaseView(View): from_class = None @property def form(self): #issubclass:参数1是不是参数2的子类,校验model_class if self.from_ 阅读全文
posted @ 2020-09-11 15:05 whcp 阅读(387) 评论(0) 推荐(0)
摘要: #利用cbv的继承特性,进行views中代码优化 #把views中的代码拆出来,新建custom_view.py,把cbv-class从views中挪进去 #自定义view,custom_view.py中新建一个BaseView 用于定义条件变量 import datetime from itert 阅读全文
posted @ 2020-09-11 15:04 whcp 阅读(233) 评论(0) 推荐(0)
摘要: # django并没有处理PUT的数据,实际上put传过来的数据在request.body# 需要导入 from django.http import QueryDict 来处理数据put_data = QueryDict(requests.body)#所以可以用middlewares实现Query 阅读全文
posted @ 2020-09-11 15:03 whcp 阅读(351) 评论(0) 推荐(0)
摘要: 全局参数(get,post,put,delete) #urls优化,不同app隔离 1-app下创建urls,在主urls中导入 使用include from django.urls import path,includefrom example import viewsurlpatterns = 阅读全文
posted @ 2020-09-11 08:52 whcp 阅读(188) 评论(0) 推荐(0)