2017-09-04 1 views
0

장고 프레임 워크로 웹 프로그래밍하는 법을 배우고 있으며 Artist 인스턴스를 만들려고 할 때이 오류 메시지가 표시됩니다. from 내 app models. 나는 파이썬 3.6 버전과 장고 1.11.4 버전을 사용한다. 도와주세요. 감사합니다.장고 1.11.4 : django.core.exceptions.AppRegistryNotReady : 앱이 아직로드되지 않았습니다.

File "<stdin>", line 1, in <module> 
     File ".\app\models.py", line 9, in <module> 
     class Artist(models.Model): 
     File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\db\models\base.py", line 110, in __new__ 
     app_config = apps.get_containing_app_config(module) 
     File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\apps\registry.py", line 247, in get_containing_app_config 
     self.check_apps_ready() 
     File "C:\Users\kadjo\documents\visual studio 2015\Projects\DatabaseFun\DatabaseFun\env\lib\site-packages\django\apps\registry.py", line 125, in check_apps_ready 
     raise AppRegistryNotReady("Apps aren't loaded yet.") 
    django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 

답변

0

이 내 모델 패키지 코드

from django.db import models 

# Create your models here. 

class Artist(models.Model): 
    name = models.CharField("artist", max_length=50) 
    year_formed = models.PositiveIntegerField() 

class Album(models.Model): 
    name = models.CharField("album", max_length=50) 
    artist = models.ForeignKey(Artist) 

인이 내 응용 프로그램 설정 패키지 코드

""" 
Django settings for DatabaseFun project. 

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

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

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

import os 
import posixpath 

# 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/1.9/howto/deployment/checklist/ 

# SECURITY WARNING: keep the secret key used in production secret! 
SECRET_KEY = 'ec5ea5b6-ee2d-43db-8bb8-4562d88788ea' 

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

ALLOWED_HOSTS = [] 


# Application definition 

INSTALLED_APPS = [ 
    'app', 
    # Add your apps here to enable them 
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'DatabaseFun', 
] 

MIDDLEWARE_CLASSES = [ 
    'django.middleware.security.SecurityMiddleware', 
    '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 = 'DatabaseFun.urls' 

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [], 
     '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 = 'DatabaseFun.wsgi.application' 


# Database 
# https://docs.djangoproject.com/en/1.9/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/1.9/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/1.9/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/1.9/howto/static-files/ 

STATIC_URL = '/static/' 

STATIC_ROOT = posixpath.join(*(BASE_DIR.split(os.path.sep) + ['static'])) 
0

먼저 당신의 setings.py 파일의 맨 위에 다음 줄을 추가합니다.

import django 
django.setup() 

그리고이이 설치된 앱 목록을 하나씩에서 타사 응용 프로그램을 제거하려고 작동하지 않는 경우. 나중에 다시로드 할 수 있습니다. 특정 타사 응용 프로그램에 대한 종속성 때문일 수 있습니다.

희망이 있습니다!

관련 문제