【发布时间】:2017-02-07 04:12:45
【问题描述】:
我正在尝试保存模型的一个实例,但得到一个 ValueError。
ValueError: Cannot assign "<DataPointModel: DataPointModel object>":
"Bike.data_point" must be a "DataPointModel" instance.
模型有一个非常简单的字段:
data_point = models.ForeignKey(DataPointModel, null=True, blank=True)
方法也是。
data_point = DataPointModel.objects.filter(
object_id=bike.reference_model.id,
).last()
watch.data_point = data_point
watch.save()
为什么不保存?
【问题讨论】:
-
如果它有效,您可以通过投票来欣赏它。
标签: python django django-models