过滤在Django中的prefetch_related [英] Filter on prefetch_related in Django
本文介绍了过滤在Django中的prefetch_related的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
但我希望有一个更简单的解决方法...
https://github.com/ionelmc/django-prefetch#example
解决方案
截至Django 1.7,可以过滤预取的对象。请参阅此SO答案和 Django文档。
Is there a way of filtering prefetched objects? I need to get the latest() of the prefetched objects but prefetch_related doesn't work if you use latest because the query is changed?
The example here does what I need but I was hoping there's a simpler workaround...
https://github.com/ionelmc/django-prefetch#example
解决方案
As of Django 1.7, filtering prefetched objects is possible. See this SO answer, and the Django documentation.
这篇关于过滤在Django中的prefetch_related的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文