내 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)
해당 외래 키 도면을 추가 할 때 데이터베이스를 삭제하고 다시 동기화 했습니까? – catherine