drf 組件

html

中間件 
    request 
    view 
    exception 
    response
    render_template
csrf原理(在這個裏面process_view)    except  protect   

rest 10個 https://www.cnblogs.com/wupeiqi/aticles/7805382.html
 通訊協議https  域名 版本 路徑 method 過濾  status 返回結果 error  Hypermedia API

面向對象3大特性
    多態
    繼承 多繼承先左邊 廣度/深度優先 經典類/新式類
    封裝 (爲了之後打包使用)
        相同一堆屬性方法封裝在類中
        構造方法將一部分數據封裝到每個對象裏面
middleware 
import json
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt,csrf_protect #免除 保護

@csrf_exempt
def uers(request):
    user_list = ['a','b']
    return HttpResponse(json.dumps(user_list))

# cbv裏面 直接加到方法無效
# 法一
class StuView(View):
    @method_decorator(csrf_exempt)
    def dispatch(self):
        print('here')
        return HttpResponse()

    def get(self):
        print('get')
        return HttpResponse()

# 法二
@method_decorator(csrf_exempt,name='dispatch')
class StuView(View):

    def get(self):
        print('get')
        return HttpResponse()
csrf_token 裝飾器
相關文章
相關標籤/搜索