AUTH_USER_MODEL指的是尚未安装的模型'myapp.EmailUser'

时间:2015-06-20 18:59:03

标签: python django

ImproperlyConfigured at /
AUTH_USER_MODEL refers to model 'myapp.EmailUser' that has not been installed

我在myapp/models/文件夹中创建了我的模型。

EmailUser类存在于user.py文件中。

模型文件夹中的__init__.py代码:

from user import *

在myapp __init__.py中有代码:

from models import EmailUser

有人可以帮我解决问题吗。

当我尝试使用runserver命令在本地运行django时,它运行正常。但是当我尝试用wsgi运行时,我正面临着这个问题。

Settings.py

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_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',
    'myapp',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'myproject.urls'

WSGI_APPLICATION = 'myproject.wsgi.application'



DATABASES = {
    'default': {
        #'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'ENGINE': 'django.db.backends.mysql',
        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'test',  # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': 'test',
        'PASSWORD': '',
        'HOST': 'localhost',
        # Empty for localhost through domain sockets or           '127.0.0.1' for localhost through TCP.
        'PORT': '',  # Set to empty string for default.
    }
}


LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True



AUTH_USER_MODEL = 'myapp.EmailUser'

STATIC_URL = '/static/'

wsgi.py

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

0 个答案:

没有答案