美文网首页
Django cannot be both deferred a

Django cannot be both deferred a

作者: 盘古_创世纪 | 来源:发表于2020-04-04 13:38 被阅读0次

student_list = Student.objects.only('name').select_related('grades')

由于是表关联,此时没有查询关联表 grades 的任何内容, 报错

修改为:
       student_list = Student.objects.only('name', 'grades__title').select_related('grades')

相关文章

网友评论

      本文标题:Django cannot be both deferred a

      本文链接:https://www.haomeiwen.com/subject/cbxjphtx.html