Django中的Django 2.2:App注册表错误。尝试了每种可用的解决方案,但互联网上没有可用的方法

时间:2019-07-05 03:30:28

标签: django

django.core.exceptions.AppRegistryNotReady:应用尚未加载。

检查了settings.py中的所有INSTALLED_APPS 注册模型,apps.py。 早些时候,当我在同一项目下使用核心和用户应用程序时,不会出现此错误。

settings.py

"""
Django settings for jam project.

Generated by 'django-admin startproject' using Django 2.2.1.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""


import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'bj))qqcyggizpqmxp9zru$pb%m@bt0--_z%$@z6!xz^$ij3#^@'


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

ALLOWED_HOSTS = []


# Application definition
#All applications are working
INSTALLED_APPS = [

    'django.contrib.admin',

    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'home.apps.HomeConfig',
    'core.apps.CoreConfig',
    'users.apps.UsersConfig',
    'crispy_forms',

]

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 = 'jam.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 = 'jam.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
from home import views
STATIC_URL = '/static/'
LOGIN_REDIRECT_URL = views.index
CRISPY_TEMPLATE_PACK= 'bootstrap4'

#managing media
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

home / models.py

from django.db import models

class OurPicks(models.Model):
    title = models.CharField(max_length=150)
    pro_id = models.AutoField
    pro_desc = models.TextField()
    size = models.CharField(max_length=200)
    quantity = models.CharField(max_length=200)
    slug = models.SlugField()
    sleeves_length = models.CharField(max_length=15)
    neck_style = models.CharField(max_length=20)
    updated = models.DateTimeField(auto_now=True)
    availability = models.BooleanField(default=True)
    orignal_price = models.FloatField(blank=True)
    discounted_price = models.FloatField(blank=True)
    image1 = models.ImageField(upload_to='media', default='')
    image2 = models.ImageField(upload_to='media', default='')
    image3 = models.ImageField(upload_to='media', default='')
    image4 = models.ImageField(upload_to='media', default='')
    color = models.CharField(max_length=200)
    JEWELLERY = 'JEWELLERY'
    KURTIS = 'KURTIS'
    LADIES_SUIT = 'LADIES_SUIT'

    CATEGORIES = [
        (JEWELLERY, 'jewellery'),
        (KURTIS, 'kurtis'),
        (LADIES_SUIT, 'ladies_suit'),

    ]
    categories = models.CharField(
        max_length=11,
        choices=CATEGORIES,
        default=None,
    )

    def __str__(self):
        return self.title

home / admin.py

from django.contrib import admin
from .models import OurPicks
from core.apps import CoreConfig,AppConfig
from core.models import Orders
# from .modelv1 import Productcolor
#class PicksAdmin(admin.ModelAdmin):
admin.site.register(OurPicks)

home / apps.py

    from django.apps import AppConfig  

django.core.exceptions.AppRegistryNotReady:应用尚未加载。

0 个答案:

没有答案