class ModelBackend
This is the default authentication backend used by Django. It authenticates using credentials consisting of a user identifier and password. For Django’s default user model, the user identifier is the username, for custom user models it is the field specified by USERNAME_FIELD (see Customizing Users and authentication).
It also handles the default permissions model as defined for User and PermissionsMixin.
has_perm(), get_all_permissions(), get_user_permissions(), and get_group_permissions() allow an object to be passed as a parameter for object-specific permissions, but this backend does not implement them other than returning an empty set of permissions if obj is not None.
-
authenticate(username=None, password=None, **kwargs) -
Tries to authenticate
usernamewithpasswordby callingUser.check_password. If nousernameis provided, it tries to fetch a username fromkwargsusing the keyCustomUser.USERNAME_FIELD. Returns an authenticated user orNone.
-
get_user_permissions(user_obj, obj=None) -
Returns the set of permission strings the
user_objhas from their own user permissions. Returns an empty set ifis_anonymousoris_activeisFalse.
-
get_group_permissions(user_obj, obj=None) -
Returns the set of permission strings the
user_objhas from the permissions of the groups they belong. Returns an empty set ifis_anonymousoris_activeisFalse.
-
get_all_permissions(user_obj, obj=None) -
Returns the set of permission strings the
user_objhas, including both user permissions and group permissions. Returns an empty set ifis_anonymousoris_activeisFalse.
-
has_perm(user_obj, perm, obj=None) -
Uses
get_all_permissions()to check ifuser_objhas the permission stringperm. ReturnsFalseif the user is notis_active.
-
has_module_perms(self, user_obj, app_label) -
Returns whether the
user_objhas any permissions on the appapp_label.
-
user_can_authenticate() -
New in Django 1.10.
Returns whether the user is allowed to authenticate. To match the behavior of
AuthenticationFormwhichprohibits inactive users from logging in, this method returnsFalsefor users withis_active=False. Custom user models that don’t have anis_activefield are allowed.
Please login to continue.