1👍
✅
You should be able to see HTTP errors in the error
handler:
$.ajax({
...
error: function (xhr, ajaxOptions, thrownError) {
if(xhr.status==403) {
alert(...);
}
}
}
You will always see the 403 in the console as that’s the HTTP response you are getting from the server.
You can simplify the test_func
to just:
class AllUsersViews(UserPassesTestMixin, View):
...
def test_func(self):
return self.request.user.is_superuser
...
Source:stackexchange.com