2

Complete Error:

"AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'webservice_again.CustomUser' that has not been installed

model.py

from builtins import ValueError
from datetime import date

import django
from django.contrib.auth.base_user import BaseUserManager
from django.contrib.auth.models import AbstractBaseUser
 from django.db import models

class CustomUserManager(BaseUserManager):

  def create_user(self, email, password= None, full_name="ABC",type = 0):
    if not email:
        raise ValueError("Email Required.")
    if not password:
        raise ValueError("Password Required.")

    user_obj =self.model(
        self.normalize_email(email)
    )
    user_obj.set_password(password)
    user_obj.full_name = full_name
    user_obj.type = type
    user_obj.save(using = self._db)
    return user_obj



 class CustomUser(AbstractBaseUser):
   email =models.EmailField(unique=True, max_length=255)
   full_name = models.CharField(max_length=255, blank=False)
   dob = models.DateField(default=date.today)
   type = models.IntegerField(default=0)
   create_time = models.DateTimeField(auto_now_add=True)

   USERNAME_FIELD = 'email'
   REQUIRED_FIELDS = ['full_name']

   objects = CustomUserManager()

   def get_full_name(self):
     return self.full_name

   def __str__(self):
    return self.full_name

settings.py

INSTALLED_APPS = [
'webservice_again',
'web_service',
'rest_framework',
'rest_framework.authtoken',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

]

AUTH_USER_MODEL = "webservice_again.CustomUser"

Guys, I know this question is duplicate, but after going through all the provided solutions, i am asking this solution.

Any help is appreciated.

shekhar
  • 161
  • 2
  • 11
Rahul G
  • 51
  • 4

1 Answers1

0

By default django looks for models in models.py. Try changing model.py file to models.py. If you somehow have a models folder which houses all your model files, then import the CustomUser model in __init__.py file located within the models folder. This should solve it!