摘要:
一、模板语法传值 url(r"^func/",views.func)def func(request): i=111 f=11.1 s='jason' l=[11,22,33] d={"username":"jason","pwd":123} t=(11,22,33) b=True se={11,2 阅读全文
摘要:
一、FBV与CBV1.FBV 基于函数的视图 def index(request): return HttpResponse(...) 2.CBV 基于类的视图——CBV会自动判断当前请求方法并自动匹配类中的方法执行 # 视图函数即可以是函数也可以是类 from django.views impor 阅读全文
摘要:
一、form表单提交文件 1.method必须是post 2.enctype参数必须是multipart/form-data (如果你把编码格式改成formdata,那么针对普通的键值对还是解析到request.POST中,将文件解析到request.FILES中) request.POST无法获取 阅读全文
摘要:
一、小白必会三板斧(视图函数必须返回一个HttpResponse对象) HttpResponse class HttpResponse: pass render def render(...): return HttpResponse(...) redirect def redirect(...) 阅读全文