完全错误:
“ AUTH_USER_MODEL指的是尚未安装的模型'%s'”%设置。AUTH_USER_MODEL django.core.exceptions.ImproperlyConfigured:AUTH_USER_MODEL指的是尚未安装的模型'webservice_again.CustomUser'
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"
伙计们,我知道这个问题是重复的,但是经过所有提供的解决方案后,我要提出这个解决方案。
感谢您的帮助。