zoukankan      html  css  js  c++  java
  • Django【进阶篇】

    本章内容

    Class View 登录验证

      首页get方法登录验证,方法一

    from django.utils.decorators import method_decorator
    
    class IndexView(TemplateView):
        template_name = "index2.html"
    
        #首页需要登录验证,那就需要写上get方法
        @method_decorator(login_required())
        def get(self, request, *args, **kwargs):
            return super(IndexView, self).get(request, *args, **kwargs)

      方法二:

    from django.contrib.auth.mixins import LoginRequiredMixin
    
    class IndexView(LoginRequiredMixin, TemplateView):
        template_name = "index2.html"                   #这里不再需要自定义get的方法了,LoginRequiredMinin方法中实现
  • 相关阅读:
    LSTM
    Realsense D435i
    ubuntu18 realsenseD435i
    net
    test
    LSTM Accuracy
    boost x64 lib
    E0443类模板 "std::unordered_set" 的参数太多
    PropertySheet
    freetype 编译
  • 原文地址:https://www.cnblogs.com/nopnog/p/8316041.html
Copyright © 2011-2022 走看看