I got 2 app: coworkers and services, each one with its own models.py
In coworkers models.py, I can "from services.models import Services".
When I try to "from coworkers.models import Status" in services models.py, I get this error message:
Traceback (most recent call last): File "/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/commands/runserver.py", line 91, in inner_run self.validate(display_num_errors=True) File "/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/base.py", line 266, in validate num_errors = get_validation_errors(s, app) File "/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/management/validation.py", line 30, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/db/models/loading.py", line 158, in get_app_errors self._populate() File "/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/db/models/loading.py", line 64, in _populate self.load_app(app_name, True) File "/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/db/models/loading.py", line 88, in load_app models = import_module('.models', app_name) File "/Users/lucas/Documents/projetos/cwk-manager/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/importlib.py", line 35, in 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", line 5, in class Services(models.Model): File "/Users/lucas/Documents/projetos/cwk-manager/cwk-manager/cwk_manager/services/models.py", line 11, in Services status = models.ForeignKey(Status) NameError: name 'Status' is not defined
--
coworker 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
services 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
-- Can someone help me to see what I am doing wrong?
Thanks in advance!