#put it to your app/shared/decorators.py and than import when required from django.core.exceptions import PermissionDenied def superuser_only(function): """ Limit view to superusers only. Usage: -------------------------------------------------------------------------- @superuser_only def my_view(request): ... -------------------------------------------------------------------------- or in urls: -------------------------------------------------------------------------- urlpatterns = patterns('', (r'^foobar/(.*)', is_staff(my_view)), ) -------------------------------------------------------------------------- """ def _inner(request, *args, **kwargs): if not request.user.is_superuser: raise PermissionDenied return function(request, *args, **kwargs) return _inner