text: from django.db import models
  from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
  # Create your models here.
  
  
  class MyAccountManager(BaseUserManager):
      # mandetory override methods are create_user and create_superuser
      def create_user(self, email, username, password=None):
          if not email:
              raise ValueError("Users must have an email address")
          if not username:
              raise ValueError("Users must have an username")
          user = self.model(
              # normalize_email converts email to lowe case if any uppercase is present
              email=self.normalize_email(email),
              username=username
          )
          user.set_password(password)
          user.save(using=self._db)
          return user
  
      def create_superuser(self, email, username, password=None):
          user = self.create_user(
              email=self.normalize_email(email),
              username=username,
              password=password,
          )
          user.is_admin = True
          user.is_staff = True
          user.is_superuser = True
          user.save(using=self._db)
          return user
  
  
  class Account(AbstractBaseUser):
      """Model definition for Account."""
  
      # TODO: Define fields here
      email = models.EmailField(max_length=80, verbose_name="email", unique=True)
      username = models.CharField(max_length=30, unique=True)
      date_joined = models.DateTimeField(verbose_name='date joined', auto_now_add=True)
      last_login = models.DateTimeField(verbose_name='last login', auto_now=True)
      is_active = models.BooleanField(default=True)
      is_admin = models.BooleanField(default=False)
      is_staff = models.BooleanField(default=False)
      is_superuser = models.BooleanField(default=False)
      # first_name = models.CharField(max_length=50)
      # last_name = models.CharField(max_length=50)
  
      USERNAME_FIELD = 'email'
      REQUIRED_FIELDS = ['username', ]
  
      objects = MyAccountManager()
  
      class Meta:
          """Meta definition for Account."""
  
          verbose_name = 'Account'
          verbose_name_plural = 'Accounts'
  
      def __str__(self):
          """Unicode representation of Account."""
          return self.email
  
      def has_perm(self, perm, obj=None):
          return self.is_admin
  
      def has_module_perms(self, app_label):
          return True
  