“用户”对象没有属性“student_set”

时间:2017-12-12 05:43:02

标签: django

class BasicInfo(models.Model):
  username = models.OneToOneField(User, on_delete=models.CASCADE)
  email = models.EmailField(max_length=250)
  abstratct=True

class Student(Basicinfo):
   #Student class definition

当我查询时:

user=user.objects.get(user="name")
student=Student.objects.get(username=user)

但是:

user.student_set.all() gives error
  

'用户'对象没有属性'student_set'??

1 个答案:

答案 0 :(得分:1)