Skip to content
19 lines (16 sloc) 658 Bytes
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import user_passes_test
def staff_member_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME,
Decorator for views that checks that the user is logged in and is a staff
member, redirecting to the login page if necessary.
actual_decorator = user_passes_test(
lambda u: u.is_active and u.is_staff,
if view_func:
return actual_decorator(view_func)
return actual_decorator
Jump to Line
Something went wrong with that request. Please try again.