how to do this
and
has pinax any app do this ?
thanks
how to do this
and
has pinax any app do this ?
thanks
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)