【发布时间】:2015-05-29 17:45:43
【问题描述】:
class Foo(models.Model):
name = CharField
createdat = DateTimeField
class Bar(models.Model):
rel = ForeignKey(Foo, related_name='bars')
createdat = DateTimeField
Foo.prefetch_related('bars').all() 给了我所有的酒吧。有什么方法我只能使用一个查询为每个Foo 获取最新的Bar?
【问题讨论】: