Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User(AbstractBaseUser, PermissionsMixin):
- mobile = models.CharField(max_length=15,unique=True)
- email = models.EmailField(unique=True)
- first_name = models.CharField(max_length=30)
- last_name = models.CharField(max_length=30,blank=True)
- date_joined = models.DateTimeField(auto_now_add=True)
- is_on_booking = models.BooleanField(default=False)
- is_acitve = models.BooleanField(default=True)
- is_staff = models.BooleanField(default=False)
- is_superuser = models.BooleanField(default=False)
- bookings_count = models.IntegerField(default=0)
- GENDER_TYPES = (('male','m'),('female','f'),('other','o'))
- gender = models.CharField(max_length=15,choices=GENDER_TYPES,blank=True)
- objects = MyUserManager()
- USERNAME_FIELD = 'mobile'
- REQUIRED_FIELDS = ['email','first_name']
- class MyUserManager(BaseUserManager):
- def _create_user(self, mobile, email, first_name, is_staff, is_superuser, password, **extra_fields):
- if not mobile:
- raise ValueError('User must give a mobile Number')
- email = self.normalize_email(email)
- user = self.model(mobile=mobile,email=email,first_name=first_name, is_staff=is_staff, is_superuser=is_superuser, **extra_fields)
- user.set_password(password)
- user.save(using=self._db)
- return user
- def create_user(self, mobile, password=None, email=None, first_name=None, **extra_fields):
- return self._create_user(mobile, email, first_name, False, False, password, **extra_fields)
- def create_superuser(self, mobile, email, first_name, password, **extra_fields):
- return self._create_user(mobile, email, first_name, True, True, password, **extra_fields)
- {
- "non_field_errors": [
- "Unable to log in with provided credentials."
- ]
- }
Add Comment
Please, Sign In to add comment