class StaffRequiredMixin(object): """ View mixin which requires that the authenticated user is a staff member (i.e. `is_staff` is True). """ @method_decorator(login_required) def dispatch(self, request, *args, **kwargs): if not request.user.is_staff: messages.error( request, 'You do not have the permission required to perform the ' 'requested operation.') return redirect(settings.LOGIN_URL) return super(StaffRequiredMixin, self).dispatch(request, *args, **kwargs)