最佳答案
我真的不明白,所以如果有人能解释一下这是怎么回事,我会非常感激的。我有两个应用程序,帐户和主题... 这是我的设置列表:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'accounts',
'themes',
)
在账户方面,我正在努力做到这一点:
from themes.models import Theme
class Account(models.Model):
ACTIVE_STATUS = 1
DEACTIVE_STATUS = 2
ARCHIVE_STATUS = 3
STATUS_CHOICES = (
(ACTIVE_STATUS, ('Active')),
(DEACTIVE_STATUS, ('Deactive')),
(ARCHIVE_STATUS, ('Archived')),
)
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=250)
slug = models.SlugField(unique=True, verbose_name='URL Slug')
status = models.IntegerField(choices=STATUS_CHOICES, default=ACTIVE_STATUS, max_length=1)
owner = models.ForeignKey(User)
enable_comments = models.BooleanField(default=True)
theme = models.ForeignKey(Theme)
date_created = models.DateTimeField(default=datetime.now)
在我的主题模型里:
class Theme(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=250)
slug = models.SlugField(unique=True, verbose_name='URL Slug')
date_created = models.DateTimeField(default=datetime.now)
class Stylesheet(models.Model):
id = models.AutoField(primary_key=True)
account = models.ForeignKey(Account)
date_created = models.DateTimeField(default=datetime.now)
content = models.TextField()
姜戈正在剔除以下错误:
from themes.models import Theme
ImportError: cannot import name Theme
这是某种循环进口问题吗?我试过使用一个懒惰的引用,但似乎也不起作用!