Django之视图层

本文目录

  • 1 视图函数
  • 2 HttpRequest对象
  • 3 HttpResponse对象
  •  4 JsonResponse
  • 5 CBV和FBV
  • 6 简单文件上传

1 视图函数
2 HttpRequest对象
-GET
-POST
-FILES
-path
-method
-get_full_path()
-body
3 HttpResponse对象
-三件套

4 JsonResponse
-HttpResponse+json
5 CBV和FBV
-基于类的视图:
-url配置 类名.as_view()
-views.py
class Test(View)
dispatch:总的分发方法
def get(self,request)
rentun HttpRequest对象
6 简单文件上传
-前端页面:form-data
-视图层:FILES(字典)根据key值取出来,拿到文件对象

posted @ 2019-01-17 18:43  ChuckXue  阅读(82)  评论(0)    收藏  举报