from django.db import models
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin


class User(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(unique=True)

    USERNAME_FIELD = 'email'

    def __init__(self, *args, **kwargs):
        super(User, self).__init__(*args, **kwargs)

        self.set_unusable_password()

from django.db import models
from django.contrib.auth.models import (
    BaseUserManager, AbstractBaseUser, PermissionsMixin)


class UserManager(BaseUserManager):
    def create_user(self, email):
        if not email:
            raise ValueError('Users must have an email address')

        user = self.model(
            email=self.normalize_email(email)
        )

        user.save(using=self._db)
        return user


class User(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(unique=True)

    objects = UserManager()

    USERNAME_FIELD = 'email'

    def __init__(self, *args, **kwargs):
        super(User, self).__init__(*args, **kwargs)

        self.set_unusable_password()

Add user manager to pass token tests
Add user manager to pass token tests

  from django.db import models
- from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
+ from django.contrib.auth.models import (
+     BaseUserManager, AbstractBaseUser, PermissionsMixin)
+ 
+ 
+ class UserManager(BaseUserManager):
+     def create_user(self, email):
+         if not email:
+             raise ValueError('Users must have an email address')
+ 
+         user = self.model(
+             email=self.normalize_email(email)
+         )
+ 
+         user.save(using=self._db)
+         return user
  
  
  class User(AbstractBaseUser, PermissionsMixin):
      email = models.EmailField(unique=True)
+ 
+     objects = UserManager()
  
      USERNAME_FIELD = 'email'
  
      def __init__(self, *args, **kwargs):
          super(User, self).__init__(*args, **kwargs)
  
          self.set_unusable_password()
  
Add user manager to pass token tests
## Code Before:
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin


class User(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(unique=True)

    USERNAME_FIELD = 'email'

    def __init__(self, *args, **kwargs):
        super(User, self).__init__(*args, **kwargs)

        self.set_unusable_password()

## Instruction:
Add user manager to pass token tests
## Code After:
from django.db import models
from django.contrib.auth.models import (
    BaseUserManager, AbstractBaseUser, PermissionsMixin)


class UserManager(BaseUserManager):
    def create_user(self, email):
        if not email:
            raise ValueError('Users must have an email address')

        user = self.model(
            email=self.normalize_email(email)
        )

        user.save(using=self._db)
        return user


class User(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(unique=True)

    objects = UserManager()

    USERNAME_FIELD = 'email'

    def __init__(self, *args, **kwargs):
        super(User, self).__init__(*args, **kwargs)

        self.set_unusable_password()
