gpt4 book ai didi

python - Django 的 models.DO_NOTHING 需要哪些参数?

转载 作者:太空宇宙 更新时间:2023-11-03 12:57:22 25 4
gpt4 key购买 nike

我搜索了 the documentation但我还没有找到任何参数的解释。

DO_NOTHING 的实现正是这样做的,所以我传入的内容应该无关紧要,但对于其他方法(例如 CASCADE),它们实际上被使用了。

我找到的最接近的解释是 a discussion级联。

collectorfieldsub_objsusing 是什么数据类型,我要传递什么值?

编辑:

我在我的模型中使用它,像这样:

class Office(models.Model):

# Office locations have a name, and a location.

display_name = models.CharField(max_length=255)

location = models.OneToOneField(
GeoLocation,
on_delete=models.DO_NOTHING(None, None, None, None)
)

最佳答案

你不应该调用 models.DO_NOTHING,你应该只是将它作为一个值传递:

location = models.OneToOneField(
GeoLocation,
on_delete=models.DO_NOTHING
)

事实上,它是一个函数是一个实现细节,而不是 API 的一部分,这就是为什么这些参数没有记录的原因。

关于python - Django 的 models.DO_NOTHING 需要哪些参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35803443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com