django在manytomanyfield中排名第一

时间:2019-02-22 17:15:53

标签: django django-models

cloud.ml.prediction.prediction_utils.PredictionError: Failed to run the provided model: Exception during running the graph: Cannot feed value of shape (1, 1) for Tensor 'input_tensors:0', which has shape '(?,)' (Error code: 2)

当我迭代组时,它返回可预测的结果。

person.groups.add(group1)#->I want to get this as first
person.groups.add(group2)
person.groups.add(group3)

当我在m2m字段上使用.first()时,它将返回不可预测的结果。

当我使用索引[0]时,它将返回可预测的结果。

for group in person.groups.all():
    #->group1 comes first etc...

这是什么原因?

0 个答案:

没有答案