AttributeError:'ManyToManyDescriptor'对象没有属性'filter'

时间:2019-03-25 14:23:49

标签: django-models

型号:models.py

class enroll(models.Model):
    classroom_id = models.ForeignKey(classroom ,on_delete=models.CASCADE)
    student_id= models.ForeignKey(User.groups.filter(name='student'),on_delete=models.CASCADE)here

错误

**student_id= models.ForeignKey(User.groups.filter(name='student'),on_delete=models.CASCADE)
AttributeError: 'ManyToManyDescriptor' object has no attribute 'filter**

0 个答案:

没有答案