在检索updatedestroy方法中获取所有对象是一个好习惯吗?
Why we need to get all object in RetrieveUpdateDestroy Method?
In real project can I do it just like this Without fear even if there is large data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们否:querySet是未评估的。这仅用作“父” QuerySet来制作QuerySet来检索,更新和删除单个对象。
实际上,对于
检索
方法,它将在末尾添加.get> .get(pk = some_pk)
,因此请查询检索该单个对象。QuerySet可用于过滤某些项目,以防止检索,更新和删除某些对象。例如,您可以使用
querySet = student.objects.filter(active = true)
只能检索Activestudent
s。We don't: the queryset is not evaluated. This is only used as a "parent" queryset to make querysets to retrieve, update, and delete a single object.
Indeed, for a
retrieve
method, it will add.get(pk=some_pk)
at the end, and thus make a query to retrieve that single object.The queryset can be used to filter certain items, to prevent retrieving, updating and removing certain objects for example. You can for example use
queryset = Student.objects.filter(active=True)
to only be able to retrieve activeStudent
s.