2017-02-16 1 views
1

Je suis encore nouveau pour Django, mais quand je lance python manage.py runserver, je reçois cette erreur:Django Apps ne sont pas encore chargé erreur

Unhandled exception in thread started by <function wrapper at 0x10363f2a8> 
Traceback (most recent call last): 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run 
    autoreload.raise_last_exception() 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception 
    six.reraise(*_exception) 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/__init__.py", line 27, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate 
    app_config = AppConfig.create(entry) 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/apps/config.py", line 90, in create 
    module = import_module(entry) 
    File "/Applications/Canopy.app/appdata/canopy-1.4.0.1938.macosx-x86_64/Canopy.app/Contents/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/Users/ashih/Desktop/ProjectX/website/mysite/toa/models.py", line 13, in <module> 
    class Absolutedollarvalue(models.Model): 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/db/models/base.py", line 105, in __new__ 
    app_config = apps.get_containing_app_config(module) 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/apps/registry.py", line 237, in get_containing_app_config 
    self.check_apps_ready() 
    File "/Users/ashih/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready 
    raise AppRegistryNotReady("Apps aren't loaded yet.") 
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 

Est-ce que cela signifie que le problème est avec INSTALLED_APPS ? toa est le nom de l'application, et toa.models.absolutedollarvalue est le nom de l'une des tables de models.py.

Quelqu'un peut-il me dire quel est mon problème? Ceci est mon settings.py:

""" 
Django settings for mysite project. 

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

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

For the full list of settings and their values, see 
https://docs.djangoproject.com/en/1.10/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/1.10/howto/deployment/checklist/ 

# SECURITY WARNING: keep the secret key used in production secret! 
SECRET_KEY = '[email protected]*vprze+^yy*v*7cucs!ein)(3_i6s+ut7&r28)520!-' 

# SECURITY WARNING: don't run with debug turned on in production! 
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', 
    'toa', 
    'toa.models.Absolutedollarvalue' 
] 

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


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

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.postgresql_psycopg2', 
     'NAME': 'px1', 
     'USER': 'ashih', 
     'PASSWORD': ' ', 
     'HOST': 'localhost', 
     'PORT': '', 
    } 
} 


# Password validation 
# https://docs.djangoproject.com/en/1.10/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.10/topics/i18n/ 

LANGUAGE_CODE = 'en-us' 

TIME_ZONE = 'America/Los_Angeles' 

USE_I18N = True 

USE_L10N = True 

USE_TZ = True 


# Static files (CSS, JavaScript, Images) 
# https://docs.djangoproject.com/en/1.10/howto/static-files/ 

STATIC_URL = '/static/' 

J'essaie d'interroger la base de données dans mon views.py et de passer ensuite à un modèle pour afficher à l'aide highcharts.js. Cependant, le serveur ne fonctionnera pas en ce moment, donc je ne peux pas savoir si mes requêtes fonctionnent ou si elles s'affichent correctement.

Faites-moi savoir si vous avez besoin de plus d'informations.

J'apprécierais vraiment toute aide. Merci!

Répondre

2

Vous devez laisser toa.models.Absolutedollarvalue sur votre INSTALLED_APPS, il est chargé pendant le chargement de votre application toa (la ligne au-dessus) Vous n'avez pas à charger vos fichiers au sein de votre application individuellement. Vous essayez maintenant de charger votre modèle en tant qu'application individuelle. Si toa est une librairie python/django que vous n'avez pas écrite, elle peut être due à un problème d'incompatibilité de version