django - 在 Django 中过滤 prefetch_related

标签 django django-1.4

有没有过滤预取对象的方法?我需要获取预取对象的 latest() 但如果您使用 latest 因为查询已更改,则 prefetch_related 不起作用?

此处的示例满足了我的需要,但我希望有一个更简单的解决方法...

https://github.com/ionelmc/django-prefetch#example

最佳答案

从 Django 1.7 开始,过滤预取对象是可能的。见 this SO answer , 和 the Django documentation .

关于django - 在 Django 中过滤 prefetch_related,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10915319/

相关文章:

python - 我如何从中间件中的 url 访问字符串

jquery - django-autocomplete-light : "The results could not be loaded"

django - 小部件调整错误 ModuleNotFoundError : No module named 'widget_tweaks' with Django forms

django - date_format Django 1.4 具有正确的时区

python - Windows virtualenv 不为 django 切换 python

Django模板条件变量赋值

python - 返回 render() 时 Django NoReverseMatch

Django QuerySet 包含重复的条目

django - 用户注册后如何保留 session 信息(Django)?

django - 既然重置消失了,如何在 Django 1.4 中删除一个应用程序的所有数据?