我正在嘗試將外鍵添加到我的Word類中。我剛剛添加了「塗鴉」與它的外鍵。 當我做的任何命令,包括sqlclear,我得到以下錯誤:doodle = models.ForeignKey(Drawing, related_name="doodle") NameError: name 'Drawing' is not defined
與Django一起運行sqlclear時出現NameError問題
這裏是我的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)
您是否刪除了數據庫並在添加該ForeignKey Drawing時再次同步? – catherine 2013-03-14 13:06:08