i'm getting a "simple" trouble when I try to add AUTH_USER_MODEL
constant to settings.py
. It returns this error, but when I look to INSTALLED_APPS
the app name that I'm still working is there. Here it is:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'PMEapp',
]
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = Path(__file__).resolve().parent.parent
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'PMEapp',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'SOSpme.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'SOSpme.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
STATIC_URL = 'static/'
MEDIA_URL = "imgs/"
MEDIA_ROOT = os.path.join(BASE_DIR, "imgs")
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static/"),
)
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
LOGIN_URL = "login"
LOGIN_REDIRECT_URL = ""
LOGOUT_REDIRECT_URL = "login"
DATE_INPUT_FORMATS = ('%d/%m/%Y','%d-%m-%Y','%Y-%m-%d')
AUTH_USER_MODEL = "PMEapp.User"
This is the error:
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'PMEapp.User' that has not been installed
The user model -> It is in models.py
These are the things I've tried to solve the problem:
1-Created a User file including all user types in PMEapp folder with user inside didn't work.
2-Moved User file to a folder called User, got the same error.
3-Put all user types in models.py but User(AbstractUser) was still in User.py . Didn't worked too.
4-I've added a User.py file in models folder and imported it to the file that got all the user types. Same error.
It looks like you forgot to add an init.py file to your models directory. Try adding that and startup your Django server again. You might need to import your models in your init file, like from .models import User