python - django tastypie - 如何在发送发布请求时停止模型创建

标签 python django tastypie

我这样做:

def hydrate(self, bundle):
     manipulate data here

现在,根据数据,我想检查它是否已经可用。如果对象尚不存在,则想要创建该对象。简单地说,想做 get_or_create。

最佳答案

你几乎没有任何代码,所以我不知道你的模型等是什么,但我认为你正在寻找的是:

Model.objects.get_or_create()

关于python - django tastypie - 如何在发送发布请求时停止模型创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16383011/

相关文章:

python - 什么 Python 框架用于没有前端的 REST/JSON Web 服务?

python - Tastypie 中的文件字段

python - Github Actions 一直卡在某个任务上,最终因超时而失败

python - Django UpdateView 不工作

python - NotImplementedError : Only tempfile. 临时文件可供使用

python - 如何使用按钮指向现有的 url

python - PUT 方法在 django-tastypie 中不起作用?

python - 在 Pandas 中为组切片设置值的最快方法

python - Python3 : creating error for input of negative

python - 如何解决 conda 中不一致的包警告?