permission_required decorator not working for me

前端 未结 5 1133
长情又很酷
长情又很酷 2021-02-04 18:24

I can\'t figure out why the permission required decorator isn\'t working. I would like to allow access to a view only for staff members. I have tried

@permission         


        
5条回答
  •  情话喂你
    2021-02-04 18:49

    This is how I would do it:

    from django.contrib.admin.views.decorators import staff_member_required
    
    @staff_member_required
    def series_info(request):
        ...
    

    The documentation says about staff_member_required:

    Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary.

提交回复
热议问题