私は2つのアプリを手に入れました:同僚とサービス、それぞれが独自のmodels.pyを持っています
同僚のmodels.pyでは、「services.modelsからサービスをインポート」できます。
servicesmodels.pyで「fromcoworkers.modelsimportStatus」を実行しようとすると、次のエラーメッセージが表示されます。
トレースバック(最後の最後の呼び出し):ファイル "/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management /commands/runserver.py "、行91、inner_run self.validate(display_num_errors = True)ファイル"/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4。 3-py2.7.egg/django/core/management/base.py "、行266、validate num_errors = get_validation_errors(s、app)ファイル" / Users / lucas / Documents / projetos / cwk-manager / lib / python2 .7 / site-packages / Django-1.4.3-py2.7.egg / django / core / management / validation.py "、行30、get_validation_errors for(app_name、error)in get_app_errors()。items():ファイル"/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7。egg / django / db / models / loading.py "、158行目、get_app_errors self._populate()ファイル" /Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django- 1.4.3-py2.7.egg/django/db/models/loading.py "、64行目、_populate self.load_app(app_name、True)ファイル" / Users / lucas / Documents / projetos / cwk-manager / lib /python2.7/site-packages/Django-1.4.3-py2.7.egg/django/db/models/loading.py "、88行目、load_appモデル= import_module('。models'、app_name)ファイル" /Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/importlib.py "、35行目、import_module_populate self.load_app(app_name、True)ファイル"/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packagesのegg/ django / db / models / loading.py"、64行目/Django-1.4.3-py2.7.egg/django/db/models/loading.py "、88行目、load_appモデル= import_module('。models'、app_name)ファイル" / Users / lucas / Documents / projetos /cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/importlib.py "、35行目、import_module_populate self.load_app(app_name、True)ファイル"/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packagesのegg/ django / db / models / loading.py"、64行目/Django-1.4.3-py2.7.egg/django/db/models/loading.py "、88行目、load_appモデル= import_module('。models'、app_name)ファイル" / Users / lucas / Documents / projetos /cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/importlib.py "、35行目、import_module/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/importlib.py "、35行目、import_module/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/importlib.py "、35行目、import_module import(name)File "/Users/lucas/Documents/projetos/cwk-manager/cwk-manager/cwk_manager/coworkers/models.py"、line 2 in from services.models import Services File "/ Users / lucas / Documents /projetos/cwk-manager/cwk-manager/cwk_manager/services/models.py "、5行目、クラスServices(models.Model):ファイル" / Users / lucas / Documents / projetos / cwk-manager / cwk-manager /cwk_manager/services/models.py "、11行目、Services status = models.ForeignKey(Status)NameError:name'Status' is not defined
-
同僚models.py
from django.db import models
from services.models import Services
class Status(models.Model):
status_name = models.CharField(max_length=50)
status_description = models.TextField(blank=True, null=True)
class Meta:
verbose_name = "Status"
verbose_name_plural = "Status"
def __unicode__(self):
return self.status_name
サービスmodels.py
from django.db import models
from coworkers.models import Status
# This table contains all the information about plans and other general services provided.
class Services(models.Model):
service_name = models.CharField(max_length=100)
service_description = models.TextField(blank=True, null=True)
service_price = models.DecimalField(max_digits=7, decimal_places=2, blank=True, null=True)
creation_date = models.DateField(auto_now_add=True)
last_update = models.DateField(auto_now=True)
status = models.ForeignKey(Status)
class Meta:
verbose_name = "Services"
verbose_name_plural = "Services"
def __unicode__(self):
return self.service_name
-誰かが私が間違っていることを確認するのを手伝ってくれますか?
前もって感謝します!