auth.mixins.UserPassesTestMixin

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

auth.mixins.PermissionRequiredMixin

class PermissionRequiredMixin New in Django 1.9. This mixin, just like the permission_required decorator, checks whether the user accessing a view has all given permissions. You should specify the permission (or an iterable of permissions) using the permission_required parameter: from django.contrib.auth.mixins import PermissionRequiredMixin class MyView(PermissionRequiredMixin, View): permission_required = 'polls.can_vote' # Or multiple of permissions: permission_required = (

auth.mixins.PermissionRequiredMixin.get_permission_required()

get_permission_required() Returns an iterable of permission names used by the mixin. Defaults to the permission_required attribute, converted to a tuple if necessary.

auth.mixins.PermissionRequiredMixin.has_permission()

has_permission() Returns a boolean denoting whether the current user has permission to execute the decorated view. By default, this returns the result of calling has_perms() with the list of permissions returned by get_permission_required().

auth.mixins.AccessMixin.login_url

login_url Default return value for get_login_url(). Defaults to None in which case get_login_url() falls back to settings.LOGIN_URL.

auth.mixins.AccessMixin.handle_no_permission()

handle_no_permission() Depending on the value of raise_exception, the method either raises a PermissionDenied exception or redirects the user to the login_url, optionally including the redirect_field_name if it is set.

auth.mixins.AccessMixin.redirect_field_name

redirect_field_name Default return value for get_redirect_field_name(). Defaults to "next".

auth.mixins.AccessMixin.get_redirect_field_name()

get_redirect_field_name() Returns the name of the query parameter that will contain the URL the user should be redirected to after a successful login. If you set this to None, a query parameter won’t be added. Returns the redirect_field_name attribute by default.

auth.mixins.AccessMixin.permission_denied_message

permission_denied_message Default return value for get_permission_denied_message(). Defaults to an empty string.

auth.mixins.AccessMixin.raise_exception

raise_exception If this attribute is set to True, a PermissionDenied exception will be raised instead of the redirect. Defaults to False.