我正在尝试搜索 ManyToMany 关系,但我做错了什么,我不确定它是什么
t = Teacher.objects.get(username=u.username)
var = list(Allowed.objects.filter(allowed=t))
这是我正在使用的课程:
class Allowed(models.Model):
owner = models.ForeignKey(Teacher, related_name='allowed_teacher')
reason = models.CharField(max_length=200, blank=True, null=True)
allowed = models.ManyToManyField(Teacher, related_name='who_is_allowed', blank=True, null=True)
我该怎么做?
编辑:
Teacher
没有任何参考 Allowed