报错内容为
Got AttributeError when attempting to get a value for field `name` on serializer `FoodSerializers`. The serializer field might be named incorrectly and not match any attribute or key on the `QuerySet` instance. Original exception text was: 'QuerySet' object has no attribute 'name'.
图片如下
解决方法
在获取数据的方法里查看使用序列化转换数据类型时是否使用了many=True
图片如下
因为使用all或filter获取的数据为查询集 查询集转换时都需要添加many=True
如果是使用的get获取时则不需要加many=True
因为get只可以获取单条数据 获取多条数据时会报错 所以不需要加many=True



