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方法中实现
  • 相关阅读:
    kvm virtio
    GPU 线程块/线程束
    ubuntu source
    React
    分布式系统
    honpeyhonepy
    css是干什么的
    bootstrap中的横的列
    数据安全之 alert logic
    viewset的使用的方法
  • 原文地址:https://www.cnblogs.com/nopnog/p/8316041.html
Copyright © 2011-2022 走看看