2017-03-28 15 views
0

私はアプリがまだロードされていないというエラーでdjangoアプリケーションを持っています。私はpostgresデータベースを使用しています。モデルを追加した後、問題が発生し始めました。モデルをインストールしたアプリケーションにモデルを追加し、モデルの下にdjangoの設定を変更し、モデルクラスに名前を追加し、モデルクラスにメタを追加しました。 django.dbインポートモデルを使用する際に問題があるかどうかはわかりません。Djangoアプリはまだロードされていません

は、ここで私はあなたがmyapps」は単に 'myapps' の代わりに追加すべきだと思う完全なエラー

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

*完全なトレースバックを表示してください。 'myapps.modelapp'を' INSTALLED_APPS'に追加するのは非常に間違っています。あなたはappかappの設定を 'INSTALLED_APPS'に追加するべきです。 'modelapp.py'とは何でしょうか?それがモデルを含んでいるなら、それを 'models.py'と名付けるのはなぜですか? – Alasdair

答えて

1

です。 INSTALLED_APPSの「modelapp」

関連する問題