tags:

views:

35

answers:

1

how to do this

and

has pinax any app do this ?

thanks

+3  A: 

Django provides a decorator for testing a user at the view-level. You can use this to enforce an "admin-only" for a given view.

from django.contrib.auth.decorators import user_passes_test

@user_passes_test(lambda u: u.is_staff)
def my_admin_only_view(request, *args, **kwargs):
    # ...

# could also test for superuser only, or whatever else you like
@user_passes_test(lambda u: u.is_superuser)
T. Stone