auth.mixins.UserPassesTestMixin.test_func()

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.request.user.email.endswith('@example.com')
doc_Django
2016-10-09 18:34:15
Comments
Leave a Comment

Please login to continue.