im getting this error
======================
match = date_re.match(value)
TypeError: expected string or bytes-like object
TypeError: expected string or bytes-like object
this is my user profile model
=======================
class UserManager(BaseUserManager):
use_in_migrations = True
def _create_user(self, email, password, **extra_fields):
"""
Creates and saves a User with the given mobile and password.
"""
if not email:
raise ValueError('The given email must be set')
# email = self.normalize_email(email)
user = self.model(email=email, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user
def create_user(self, email, password=None, **extra_fields):
extra_fields.setdefault('is_superuser', False)
return self._create_user(email, password, **extra_fields)
def create_superuser(self, email, password, **extra_fields):
extra_fields.setdefault('is_superuser', True)
extra_fields.setdefault('is_staff', True)
if extra_fields.get('is_superuser') is not True:
raise ValueError('Superuser must have is_superuser=True.')
return self._create_user(email, password, **extra_fields)
class Teams(models.Model):
teamname = models.CharField(max_length=100,unique=True)
team_description = models.CharField(max_length=1024)
def __str__(self):
return self.teamname
class UserProfile(AbstractBaseUser, PermissionsMixin):
id=models.AutoField(primary_key=True)
username = models.CharField(max_length=200, unique=True, null=True, blank=True)
fullname = models.CharField(_('name'), max_length=200, blank=True, null=True)
mobile = models.CharField(_('mobile'), unique=True, max_length=10, blank=True, null=True)
email = models.EmailField(_('email address'), unique=True, blank=True, null=True)
password = models.CharField(_('password'),max_length=25,blank=True, null=True)
date_joined = models.DateTimeField(verbose_name="date joined", auto_now_add=True,)
is_verified = models.BooleanField(default=True,)
is_active = models.BooleanField(_('active'), default=True)
is_staff = models.BooleanField(_('is_staff'), default=True)
is_admin = models.BooleanField(_('is_Admin'), default=False, blank=True, null=True)
is_manager = models.BooleanField(_('is_Manger'), default=False, blank=True, null=True)
is_tl = models.BooleanField(_('is_Tl'), default=False, blank=True, null=True)
is_agent = models.BooleanField(_('is_Agent'), default=False, blank=True, null=True)
orginization = models.CharField(max_length=200, null=True, default=False)
dob=models.DateField(default=False)
GENDER_CHOICES = (
('Male', 'Male'),
('Female', 'Female'),
)
Roles = (
('Manager', 'Manager'),
('TL', 'TL'),
('Admin', 'Admin'),
('Agent', 'Agent'),)
gender = models.CharField(max_length=8, choices=GENDER_CHOICES, null=True)
team_name = models.ForeignKey(Teams, on_delete=models.CASCADE, default=False, null=True, related_name='person_team')
role = models.CharField(max_length=100, null=True, choices=Roles, default=False)
objects = UserManager()
USERNAME_FIELD = 'email' # User should be able to login with
REQUIRED_FIELDS = []
class Meta:
verbose_name = _('user')
verbose_name_plural = _('users')
def get_full_name(self):
'''
Returns the first_name plus the last_name, with a space in between.
'''
full_name = '%s %s' % (self.name)
return full_name.strip()
def get_short_name(self):
'''
Returns the short name for the user.
'''
return self.name
def create_superuser(self, password, email):
"""
Creates and saves a superuser with the given username and password.
"""
user = self.create_user(
email=email,
password=password,
)
user.is_superuser = True
user.is_staff = True
user.save(using=self._db)
return user
remaining models also there with date and time field
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMCU6Cr8U3ZN1GGUVkPCnXwEJTyOm7BV3Vxx742sZ%3DfPSX4Fjw%40mail.gmail.com.
No comments:
Post a Comment