def superuser_required(view):
 @wraps(view)
 def decorated(request, *args, **kwargs):
  if (not request.user.is_authenticated()):
   return login(request, template_name='admin/login.html', authentication_form=AdminAuthenticationForm, extra_context={'title': _('Log in'), 'app_path': request.get_full_path(), REDIRECT_FIELD_NAME: request.get_full_path()})
  if (not (request.user.is_active and request.user.is_superuser)):
   return render_to_response('admin/permission_denied.html', {'request': request, 'user': request.user})
  return view(request, *args, **kwargs)
 return decorated

def superuser_required ( view ) : @ wraps ( view ) def decorated ( request , * args , ** kwargs ) : if ( not request . user . is_authenticated ( ) ) : return login ( request , template_name = 'admin/login.html' , authentication_form = AdminAuthenticationForm , extra_context = { 'title' : _ ( 'Log in' ) , 'app_path' : request . get_full_path ( ) , REDIRECT_FIELD_NAME : request . get_full_path ( ) } ) if ( not ( request . user . is_active and request . user . is_superuser ) ) : return render_to_response ( 'admin/permission_denied.html' , { 'request' : request , 'user' : request . user } ) return view ( request , * args , ** kwargs ) return decorated
wrap a view so that is only accessible to superusers .