class User(AbstractUser): username = None role = models.CharField(max_length=12, error_messages={ 'required': "Role must be provided" }) gender = models.CharField(max_length=10, blank=True, null=True, default="") hotline = models.CharField(max_length=15,null=False,default='') email = models.EmailField(unique=True, blank=False, error_messages={ 'unique': "Email của bạn đã tồn tại.", }) # update thanh_phos = models.ForeignKey(ThanhPho, on_delete=models.CASCADE,null=True, verbose_name="Chọn Thành Phố", ) nganh_nghes = models.ForeignKey(NganhNghe, on_delete=models.CASCADE,null=True, verbose_name="Chọn Ngành Nghề",) hinh = models.ImageField("Avatar ", upload_to='uploads/User/avatar/%Y/%m/%d/',default='uploads/User/unknown.png',null=True,) skill = models.ManyToManyField(KyNang, verbose_name="Chọn kỹ năng", default='') sologan = models.CharField("Chức danh",max_length=50, blank=True, null=True, default='') description = models.TextField("Giới Thiệu", max_length=300, blank=True, null=True, default="") year_exp = models.CharField("Trình Độ", max_length=300, default='',null=True) # end update USERNAME_FIELD = "email" REQUIRED_FIELDS = [] def __unicode__(self): return self.email objects = UserManager()
class User(AbstractBaseUser, PermissionsMixin): name = models.CharField(max_length=255, null=False) # as phone number can be max 15 digits globally # and must have index constraint phone_number = models.CharField(max_length=15, db_index=True) email = models.EmailField(max_length=75, unique=True) is_superuser = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) USERNAME_FIELD = 'email' # Email & Password are required by default. REQUIRED_FIELDS = [] # Tells Django that the UserManager class defined # above should manage objects of this type. objects = UserManager() def __str__(self): """ Returns a string representation of this `User` """ return self.name def get_absolute_url(self): return "/user/%i/" % (self.pk) def set_password(self, password): """ Should set password field. Would not save the instance, though. """ self.password = password return
class User(AbstractBaseModel, AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('email address'), max_length=255, unique=True) name = models.CharField(_('name'), max_length=30, blank=True) is_staff = models.BooleanField(_('staff status'), default=False) is_active = models.BooleanField(_('active'), default=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [ 'name', ] objects = UserManager() class Meta: db_table = 'auth_user' verbose_name = _('user') verbose_name_plural = _('users') def __str__(self): return self.email def email_user(self, subject, message, from_email=None, **kwargs): send_mail(subject, message, from_email, [self.email], **kwargs) def clean(self): super().clean() if self.is_superuser and not self.is_staff: self.is_staff = True
class User(AbstractBaseUser): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) email = models.EmailField(_('email address'), unique=True) password = models.CharField(_('password'), max_length=128) first_name = models.CharField(_('first name'), max_length=255, null=True, blank=True) last_name = models.CharField(_('last name'), max_length=255, null=True, blank=True) created_at = models.DateTimeField(_('created at'), auto_now_add=True) updated_at = models.DateTimeField(_('updated at'), auto_now=True) is_superuser = models.BooleanField(_('is superuser'), default=False) last_request = models.DateTimeField(_('last request'), blank=True, null=True) is_staff = models.BooleanField( _('staff status'), default=False, help_text=_( 'Designates whether the user can log into this admin site.'), ) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = []
class User(AbstractUser): username = None role = models.CharField( max_length=12, error_messages={"required": "Role must be provided"}, verbose_name=_("Role"), help_text=_("User role."), ) gender = models.CharField( max_length=10, blank=True, null=True, default="", verbose_name=_("Gender"), help_text=_("User gender."), ) email = models.EmailField( unique=True, blank=False, error_messages={ "unique": _("A user with that email already exists."), }, verbose_name=_("Email"), help_text=_("User email, also used as username."), ) USERNAME_FIELD = "email" REQUIRED_FIELDS: List[str] = [] def __str__(self): return self.email objects = UserManager()
class User(AbstractUser): username = None role = models.CharField( max_length=12, error_messages={'required': "Role must be provided"}) gender = models.CharField(max_length=10, blank=True, null=True, default="") email = models.EmailField(unique=True, blank=False, error_messages={ 'unique': "A user with that email already exists.", }) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] def __unicode__(self): return self.email # def get_search_skillset(self): # return self.skills # def get_search_experienceset(self): # return self.experiences.only("title","entreprise") objects = UserManager()
class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('Email Address'), unique=True) first_name = models.CharField(_('First Name'), max_length=30, blank=True) last_name = models.CharField(_('Last Name'), max_length=30, blank=True) date_joined = models.DateTimeField(_('Date Joined'), auto_now_add=True) is_active = models.BooleanField(_('Active'), default=True) is_staff = models.BooleanField(_('Staff'), default=False) avatar = models.ImageField(upload_to='avatars/', null=True, blank=True) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class Meta: verbose_name = _('user') verbose_name_plural = _('users') def get_full_name(self): full_name = '%s %s' % (self.first_name, self.last_name) return full_name.strip() def get_short_name(self): return self.first_name def __str__(self): return f'{self.email}'
class User(AbstractUser): username = None role = models.CharField( max_length=12, error_messages={'required': "Role must be provided"}) gender = models.CharField(max_length=10, blank=True, null=True, default="") email = models.EmailField(unique=True, blank=False, error_messages={ 'unique': "A user with that email already exists.", }) phone_number = models.CharField( unique=True, blank=True, null=True, max_length=20, error_messages={ 'unique': "A user with that phone number already exists." }) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] def __unicode__(self): return self.email objects = UserManager()
class User(AbstractBaseUser): """Overridden django user model.""" EMAIL_FIELD = "email" USERNAME_FIELD = "email" REQUIRED_FIELDS = () email = EmailField(_("email address"), unique=True) group = ForeignKey(Group, CASCADE, related_name="users") objects = UserManager() deleted = BooleanField(default=False) @property def is_active(self): """ Check if the user is deleted or not. :return: Whether or not this user is deleted. :rtype: bool """ return not self.deleted def clean(self): """ Overridden because there is no real username. """ self.email = self.__class__.objects.normalize_email(self.email)
class User(AbstractUser): username = models.CharField(max_length=100, unique=True, blank=False, default='', error_messages={ 'required': "Username must be provided.", 'unique': "A user with that username already exists." }) role = models.CharField( max_length=12, error_messages={'required': "Role must be provided"}) email = models.EmailField(unique=True, blank=False, error_messages={ 'unique': "A user with that email already exists.", }) is_active = models.BooleanField(default=True) REQUIRED_FIELDS = ["email"] def __unicode__(self): return self.email objects = UserManager()
class User(AbstractUser): username = models.CharField( _('username'), max_length=150, null=True, blank=True, help_text=_('Required. 150 characters or fewer. Letters, ' 'digits and @/./+/-/_ only.')) email = models.EmailField(_('email address'), unique=True) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class Meta: verbose_name = _('User') verbose_name_plural = _('Users') def __str__(self): if self.first_name and self.last_name: return ' '.join([self.first_name, self.last_name]).strip() elif self.first_name: return self.first_name else: return self.email.split('@')[0]
class User(AbstractBaseUser, PermissionsMixin, SoftDeleteModel): """ An abstract base class implementing a fully featured User. """ # id = models.UUIDField(primary_key=True,unique=True, default=uuid.uuid4, editable=False) email = models.EmailField(max_length=40, unique=True) first_name = models.CharField(max_length=30, blank=True) last_name = models.CharField(max_length=30, blank=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) date_joined = models.DateTimeField(default=timezone.now) created_at = models.DateTimeField(auto_now_add=True, editable=False) updated_at = models.DateTimeField(auto_now=True, editable=False) bio = models.TextField(max_length=500, blank=True, null=True) objects = UserManager() USERNAME_FIELD = "email" REQUIRED_FIELDS = ["first_name", "last_name"] def save(self, *args, **kwargs): super(User, self).save(*args, **kwargs) return self def __str__(self): return self.email
class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('email address'), unique=True) first_name = models.CharField(_('first name'), max_length=30, blank=True) last_name = models.CharField(_('last name'), max_length=30, blank=True) date_joined = models.DateTimeField(_('date joined'), auto_now_add=True) is_active = models.BooleanField(_('active'), default=True) is_staff = models.BooleanField(_('staff'), default=True) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class Meta: db_table = "User" verbose_name = _('user') verbose_name_plural = _('users') def __str__(self): return self.get_full_name() def get_full_name(self): ''' Returns the first_name plus the last_name, with a space in between. ''' full_name = '%s %s' % (self.first_name, self.last_name) return full_name.strip() def get_short_name(self): ''' Returns the short name for the user. ''' return self.first_name def email_user(self, subject, message, from_email=None, **kwargs): ''' Sends an email to this User. ''' send_mail(subject, message, from_email, [self.email], **kwargs)
class User(AbstractUser): username = None first_name = None last_name = None email = models.EmailField(_('email address'), blank=False, null=False, unique=True) is_employer = models.BooleanField(_('employer'), blank=False, null=False, default=False) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [ 'is_employer', ] class Meta: verbose_name = _('user') verbose_name_plural = _('users') def __str__(self): return str(self.email)
class User(AbstractUser): email = models.EmailField(unique=True) email_verify_code = models.CharField(blank=True, null=True, max_length=6) email_verified_at = models.DateTimeField(blank=True, null=True) phone = models.CharField(blank=True, null=True, max_length=32) phone_verify_code = models.CharField(blank=True, null=True, max_length=6) phone_verified_at = models.DateTimeField(blank=True, null=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = UserManager() def __str__(self): return self.username def sms_to_verify(self): code = get_random_string(length=6, allowed_chars='1234567890') self.phone_verify_code = code self.save() account_sid = "" auth_token = "" client = Client(account_sid, auth_token) message = client.messages.create( to=self.phone, from_="+16672132798", body='Hi, thanks for Joining to CRICLICK. Verification code: ' + code, ) print(message.sid) return message.sid
class User(AbstractUser): username = None role = models.CharField( max_length=12, error_messages={'required': "Role must be provided"}) gender = models.CharField(max_length=10, blank=True, null=True, default="Other", choices=GENDER_CHOICES) YearofStudy = models.CharField(max_length=20, default="First Year", choices=YEAR_CHOICES) RegNo = models.CharField(max_length=9, default="12u10888") Dept = models.CharField(max_length=9, default="CSE", choices=Dept_Choices) email = models.EmailField(unique=True, blank=False, error_messages={ 'unique': "A user with that email already exists.", }) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] def __unicode__(self): return self.email objects = UserManager()
class User(AbstractUser): # id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) username = None first_name = None last_name = None email = models.EmailField(verbose_name='email address', max_length=255, unique=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) is_verified = models.BooleanField(default=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] # Tells Django that the UserManager class defined above should manage # objects of this type. objects = UserManager() def __str__(self): return self.email class Meta: ''' to set table name in database ''' ordering = ['email']
class Customer(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('Email Address'), unique=True) first_name = models.CharField(_('First Name'), max_length=30, blank=True) last_name = models.CharField(_('Last Name'), max_length=30, blank=True) credit_card = models.CharField(_('Credit Card'), max_length=100, null=True, blank=True) adddres_1 = models.CharField(_('Address 1'), max_length=100, null=True, blank=True) address_2 = models.CharField(_('Address 2'), max_length=100, null=True, blank=True) city = models.CharField(_('City'), max_length=100, null=True, blank=True) region = models.CharField(_('Region'), max_length=100, null=True, blank=True) postal_code = models.CharField(_('Postal Code'), max_length=100, null=True, blank=True) country = models.CharField(_('Country'), max_length=100, null=True, blank=True) shipping_region = models.ForeignKey('shipping.ShippingRegion', on_delete=models.CASCADE, related_name='Customers', null=True, blank=True) day_phone = models.CharField(max_length=100, null=True, blank=True) eve_phone = models.CharField(max_length=100, null=True, blank=True) mob_phone = models.CharField(max_length=100, null=True, blank=True) is_activate = models.BooleanField(_('Activate'), default=True) is_staff = models.BooleanField(_('Staff'), default=False) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class Meta: verbose_name = 'user' verbose_name_plural = 'users' def get_full_name(self): full_name = f'{self.first_name} {self.last_name}' return full_name.strip() def get_short_name(self): return self.first_name def __str__(self): return f'{self.email}'
class User(AbstractBaseUser, PermissionsMixin): u_id = models.UUIDField(default=uuid4, editable=False) first_name = models.CharField(max_length=125) last_name = models.CharField(max_length=125, null=True, blank=True) email = models.EmailField(max_length=75, db_index=True, unique=True) is_superuser = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] # Email & Password are required by default. class Meta: verbose_name = 'user' verbose_name_plural = 'users' # Tells Django that the UserManager class defined above should manage # objects of this type. objects = UserManager() def __str__(self): """ Returns a string representation of this `User`. """ return self.email @property def name(self): return f'{self.first_name} {self.last_name}' @property def token(self): """ Allows us to get a user's token by calling `user.token` instead of `user.generate_jwt_token(). """ return self._generate_jwt_token() @classmethod def by_uid(self, uid): qs = self.objects.filter(u_id=uid) if qs.exists(): return qs.first() return None def _generate_jwt_token(self): """ Generates a JSON Web Token that stores this user's ID and has an expiry date set to 60 days into the future. """ dt = datetime.now() + timedelta(days=60) token = jwt_encode(dict( id=self.pk, exp=int(dt.strftime('%s')) ), settings.SECRET_KEY, algorithm='HS256') return token.decode('utf-8')
class User(AbstractBaseUser, PermissionsMixin): u_id = models.UUIDField(default=uuid4, editable=False) name = models.CharField(max_length=255) # as phone number can be max 15 digits globally and must be unique phone_number = models.CharField(max_length=15, unique=True) email = models.EmailField(max_length=75, null=True, blank=True) spam_count = models.IntegerField(default=0) is_superuser = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) USERNAME_FIELD = 'phone_number' REQUIRED_FIELDS = ['name', 'password'] class Meta: verbose_name = 'user' verbose_name_plural = 'users' # Tells Django that the UserManager class defined above should manage # objects of this type. objects = UserManager() def __str__(self): """ Returns a string representation of this `User` setting name here as number can be confusing. """ return self.name @property def token(self): """ Allows us to get a user's token by calling `user.token` instead of `user.generate_jwt_token(). """ return self._generate_jwt_token() @classmethod def by_uid(self, uid): qs = self.objects.filter(u_id=uid) if qs.exists(): return qs.first() return None def _generate_jwt_token(self): """ Generates a JSON Web Token that stores this user's ID and has an expiry date set to 60 days into the future. """ dt = datetime.now() + timedelta(days=60) token = jwt_encode(dict(id=self.pk, exp=int(dt.strftime('%s'))), settings.SECRET_KEY, algorithm='HS256') return token.decode('utf-8')
class MainUser(AbstractUser): ident_code = models.IntegerField(unique=True) REQUIRED_FIELDS = ['ident_code'] objects = UserManager() @staticmethod def exist_balance(balance, amount): return balance >= amount
class User(AbstractBaseUser): email = models.EmailField( verbose_name=_('Adresse email'), max_length=255, unique=True, ) first_name = models.CharField(max_length=50, blank=True, verbose_name=_('Prenom')) last_name = models.CharField(max_length=50, blank=True, verbose_name=_('Nom')) date_joined = models.DateTimeField(auto_now=False, auto_now_add=True, verbose_name=_('Date d\'inscription')) last_login = models.DateTimeField(default=timezone.now, verbose_name=_('Dernière connexion')) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_member = models.BooleanField(default=False, verbose_name=_('Membre')) admin = models.BooleanField(default=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = UserManager() def get_full_name(self): if self.first_name and self.last_name: return self.first_name + ' ' + self.last_name return self.email def get_short_name(self): return self.email def __str__(self): if self.is_admin: return 'Admin' return self.email def has_perm(self, perm, obj=None): return True def has_module_perms(self, app_label): return True @property def is_admin(self): return self.admin class Meta: verbose_name = _("Utilisateur") verbose_name_plural = _("Utilisateurs")
class User(AbstractBaseUser, PermissionsMixin, BaseModel): email = models.EmailField(unique=True) name = models.CharField(max_length=100) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] objects = UserManager() def __str__(self): return self.email
class User(AbstractBaseUser, PermissionsMixin): alias = models.UUIDField(primary_key=True, default=uuid4, editable=False) email = models.EmailField(unique=True) phone = models.CharField(max_length=100, null=True, blank=True) avatar = models.ImageField(null=True, blank=True) first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['first_name', 'last_name']
class User(AbstractBaseUser, PermissionsMixin): username = models.CharField(max_length=45, unique=True, db_index=True, primary_key=True) email = models.EmailField('email address', unique=True) objects = UserManager() USERNAME_FIELD = 'username' REQUIRED_FIELDS = [] class Meta: db_table = "users" verbose_name = 'user' verbose_name_plural = 'users'
class User(AbstractUser): username = None email = models.EmailField(unique=True) firebase_uid = models.CharField(max_length=128) is_admin = models.BooleanField(default=False) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] objects = UserManager() class Meta: indexes = [models.Index(fields=["firebase_uid"])] def __str__(self): return self.email
class User(AbstractBaseUser, PermissionsMixin): username = models.CharField( max_length=30, unique=True, validators=[ validators.RegexValidator( re.compile('^[\w.@+-]+$'), 'Username must contain only letters, digits or the ' 'following characters: @/./+/-/_', 'invalid') ]) email = models.EmailField(verbose_name='e-mail', unique=True) name = models.CharField(verbose_name='name', max_length=100, blank=True) is_active = models.BooleanField(verbose_name='is active?', blank=True, default=True) is_staff = models.BooleanField(verbose_name='is staff?', blank=True, default=False) date_joined = models.DateTimeField(verbose_name='joined in', auto_now_add=True, editable=False) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['email'] objects = UserManager() def __str__(self): return self.username def get_full_name(self): return self.username def get_short_name(self): return self.username def email_user(self, subject, message, from_email=None, **kwargs): ''' Sends an email to this User. ''' send_mail(subject, message, from_email, [self.email], **kwargs) class Meta: verbose_name = 'User' verbose_name_plural = 'Users'
class User(AbstractUser): username = None role = models.CharField( max_length=12, error_messages={'required': "Role must be provided"}) gender = models.CharField(max_length=10, blank=True, null=True, default="") hotline = models.CharField(max_length=15, null=False, default='') email = models.EmailField(unique=True, blank=False, error_messages={ 'unique': "Email của bạn đã tồn tại.", }) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] def __unicode__(self): return self.email objects = UserManager()
class User(AbstractBaseUser): email = EmailField(unique=True) first_name = CharField(max_length=255) last_name = CharField(max_length=255) username = CharField(max_length=255,unique=True) active = BooleanField(default=True) admin = BooleanField(default=False) staff = BooleanField(default=False) bio = TextField(blank=True) profession = CharField(max_length=255,blank=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['username','first_name','last_name'] def get_full_name(self): return "{0} {1}".format(self.first_name,self.last_name) def get_short_name(self): return self.username def __str__(self): return self.email def has_perm(self,perm,obj=None): return True def has_module_perms(self,app_label): return True @property def is_staff(self): return self.staff @property def is_active(self): return self.active @property def is_admin(self): return self.admin objects = UserManager()
class User(AbstractBaseUser, PermissionsMixin): """ Custom User Model """ email = models.EmailField(_('email address'), unique=True) full_name = models.CharField(_('full name'), max_length=64, blank=True) date_joined = models.DateTimeField(_('date joined'), auto_now_add=True) is_active = models.BooleanField(_('active'), default=True) is_staff = models.BooleanField(_('staff'), default=True) avatar = models.ImageField(upload_to='avatars/', null=True, blank=True) online = models.BooleanField(default=False) objects = UserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class Meta: verbose_name = _('user') verbose_name_plural = _('users') def email_user(self, subject, message, from_email=None, **kwargs): send_mail(subject, message, from_email, [self.email], **kwargs)