2017-03-28 100 views
0

我有一个Django应用程序,错误应用程序尚未加载。我正在使用postgres数据库。添加模型后发生问题。我尝试将模型添加到已安装的应用程序中,将django设置更改为模型下方,向模型类中添加名称,将元素添加到模型类中。我不确定使用django.db导入模型是否存在问题。Django应用程序尚未加载

以下是完整的错误

raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps arne't loaded yet. 

settings.py

import os 


SECRET_KEY = 'secret_key' 

# 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! 


# 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', 
    'django.contrib.gis', 
    'django.contrib.sites', 
    'myapps.modelapp' 
] 

modelapp.py

from django.db import models 
from django.contrib.postgres.fields import ArrayField 

class AppClass(models.Model): 
    name = 'modelapp' 
    verbose_name = 'modelapp' 
    # Regular Django fields corresponding to the attributes in the 
    # world borders shapefile. 
    data_1 = models.CharField('data_1', max_length=30) 

    # Returns the string representation of the model. 
    def __str__(self):    # __unicode__ on Python 2 
     return self.parcel_own 

    class Meta: 
     managed = True 
     db_table = 'table_name' 
+1

请显示* full * traceback。将'myapps.modelapp'添加到'INSTALLED_APPS'看起来非常错误。您应该将应用程序或应用程序配置添加到'INSTALLED_APPS'。什么是'modelapp.py'应该是?如果它包含模型,那么为什么不把它命名为'models.py'? – Alasdair

回答

1

我想你应该添加的“安装MyApps只是 '安装MyApps' 代替。 modelapp'in INSTALLED_APPS。

相关问题