1. Django staff member required

    Here is a simple decorator that isn’t mentioned properly in the Django documentation.

    @staff_member_required

    It basically checks to see if the user is logged in and has is_staff before allowing a user access to the view. Use like you would the normal
    @login_required decorator.

    from django.shortcuts import render_to_response
    from django.template.context import RequestContext
    from django.contrib.admin.views.decorators import staff_member_required


    @staff_member_required
    def my_view(request):
       
        return render_to_response('page.html',
                                  context_instance=RequestContext(request))
    By timc3 on the
    March 13th, 2010

Comment

  1. Thanks i had been trying to find out how to do this

    Hugoagogo Says:
    August 13th, 2010 at 12:13 pm

Please post a comment