我正在为我的 django 站点创建模型(python,如果不明显的话)。
from django.db import models
class Picture(models.Model):
name = models.CharField(max_length=100)
pub_date = models.DateTimeField('date published')
tags = models.ManyToManyField(Tag)
owner = models.ForeignKey(User)
class Tag(models.Model):
pics = models.ManyToManyField(Picture)
name = models.CharField(max_length=30)
class User(models.Model):
name = models.CharField(max_length=20)
date_joined = models.DateTimeField('date joined')
class Comment(models.Model):
content = models.CharField(max_length=500)
date = models.DateTimeField('date commented')
commenter = models.ForeignKey(User)
pic = models.ForeignKey(Picture)
这是整个当前模型,但我在行上遇到错误tags = models.ManyToManyField(Tag)
,说“NameError:名称'Tag'未定义”
这有什么关系?