Is there a decorator in django similar to @login_required that also tests if the user is a superuser?
Thanks
To require a superuser on a class based view without writing new code:
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import user_passes_test
@method_decorator(user_passes_test(lambda u: u.is_superuser), name='dispatch')
class AdminCreateUserView(LoginRequiredMixin, FormView):
...
...
...