class UserPassesTestMixin
New in Django 1.9.
When using class-based views, you can use the UserPassesTestMixin to do this.
test_func()
You have to override the test_func() method of the class to provide the test that is performed. Furthermore, you can set any of the parameters of AccessMixin to customize the handling of unauthorized users: from django.contrib.auth.mixins import UserPassesTestMixin
class MyView(UserPassesTestMixin, View):
def test_func(self):
return self.re