Created
July 4, 2023 14:00
-
-
Save mansha99/dac40acf333019e632dc8ed9fa8dac5a to your computer and use it in GitHub Desktop.
notice_app/notices/models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin | |
from django.db import models | |
from django.utils import timezone | |
from django.utils.translation import gettext_lazy as _ | |
from .managers import CustomUserManager | |
from django.core.validators import RegexValidator | |
phone_validator = RegexValidator(r"^[7-9]{1}[0-9]{9}$", "Exactly 10 digits are required") | |
class CustomUser(AbstractBaseUser, PermissionsMixin): | |
mobile = models.CharField(max_length=16, validators=[phone_validator], unique=True) | |
full_name = models.CharField(max_length=30) | |
is_staff = models.BooleanField(default=False) | |
is_superuser = models.BooleanField(default=False) | |
is_active = models.BooleanField(default=True) | |
date_joined = models.DateTimeField(default=timezone.now) | |
USERNAME_FIELD = "mobile" | |
REQUIRED_FIELDS = ['full_name'] | |
objects = CustomUserManager() | |
def __str__(self): | |
return self.mobile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment