Django中的dispatch方法


class InfoMG(View):
    @method_decorator(csrf_exempt)
    @method_decorator(login_required)
    def dispatch(self, request, *args, **kwargs):
        return super(InfoMG, self).dispatch(request, *args, **kwargs)

    def get(self, request):
        pass

    def post(self, request):
     pass

簡單說作用就是當請求的get或者post的方法之前執行這個dispatch方法,如果定義了什么變量函數都會先執行  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM