text: from re import U
  from django.db import models
  from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, \
                                      PermissionsMixin
  
  class UserManager(BaseUserManager):
  
      def create_user(self, email, password=None, **extra_fields):
          """Create and save a new user"""
          if not email:
              raise ValueError("Users must have an email address")
          user = self.model(email=self.normalize_email(email), **extra_fields)
          #Set user password using the .set_password() method for encryption
          #purposes
          user.set_password(password)
          user.save(using=self.db)
  
          return user
  
      def create_superuser(self, email, password):
          """Creates and saves a new super user"""
          user = self.create_user(email, password=password)
          user.is_staff = True
          user.is_superuser = True
          user.save(using=self._db)
  
          return user
  
  class User(AbstractBaseUser, PermissionsMixin):
      """Custom user model that support using email instead of username"""
      email = models.EmailField(max_length=255, unique=True)
      name = models.CharField(max_length=255)
      is_active = models.BooleanField(default=True)
      is_staff = models.BooleanField(default=False)
  
      objects = UserManager()
  
      USERNAME_FIELD = "email"