本文整理汇总了Python中django.contrib.auth.models.BaseUserManager.from_queryset方法的典型用法代码示例。如果您正苦于以下问题:Python BaseUserManager.from_queryset方法的具体用法?Python BaseUserManager.from_queryset怎么用?Python BaseUserManager.from_queryset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.auth.models.BaseUserManager
的用法示例。
在下文中一共展示了BaseUserManager.from_queryset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OreUserManager
# 需要导入模块: from django.contrib.auth.models import BaseUserManager [as 别名]
# 或者: from django.contrib.auth.models.BaseUserManager import from_queryset [as 别名]
from ore.core.models import Namespace, Organization
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, AnonymousUser, BaseUserManager
from django.contrib.contenttypes.models import ContentType
from django.core.mail import send_mail
from django.db import models
from django.db.models import Q
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _t
import hashlib
from ore.core.util import UserFilteringQuerySet
from reversion import revisions as reversion
OreUserManagerBase = BaseUserManager.from_queryset(UserFilteringQuerySet)
class OreUserManager(OreUserManagerBase):
def create_user(self, name, password=None, email=None, **extra_fields):
now = timezone.now()
email = self.normalize_email(email)
user = self.model(
name=name,
**extra_fields
)
user.set_password(password)
# we'll create a superuser if this is the only user
if not self.exists():
user.is_staff = True
user.is_superuser = True