我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用django.contrib.auth.models.PermissionsMixin()。
def test_base_class_is_permissions_mixin(self): self.assertTrue(issubclass(User, PermissionsMixin)) ################################## # fields # ##################################
def has_perm(self, perm, obj=None): """ Override PermissionsMixin has_perm to deactivate is_superuser if authenticated through a token """ # Active superusers have all permissions. if self.is_active and self.is_superuser and not hasattr(self, 'token'): return True # Otherwise we need to check the backends. return _user_has_perm(self, perm, obj)