我正在尝试向我的 Word 类添加一个外键。我刚刚用它的外键添加了“doodle”。当我执行任何命令(包括 sqlclear)时,我收到以下错误:doodle = models.ForeignKey(Drawing, related_name="doodle")
NameError: name 'Drawing' is not defined
这是我的models.py:
from django.db import models
from django.contrib.auth.models import User
class Word(models.Model):
doodle = models.ForeignKey(Drawing, related_name="doodle")
word = models.CharField(max_length=200)
definition = models.TextField()
def __unicode__(self):
return unicode(self.word)
class Drawing(models.Model):
word = models.ForeignKey(Word, related_name="drawings")
doodle = models.TextField()
flags = models.IntegerField(default=0)
kudos = models.IntegerField(default=0)