Django里filter用法和Foo_set用法

2017-09-03  本文已影响0人  findDream1122
>>> e = Entry.objects.get(id=2)
>>> e.blog
>>> b = Blog.objects.get(id=1)
>>> b.entry_set.all() # Returns all Entry objects related to Blog.

# b.entry_set is a Manager that returns QuerySets.
>>> b.entry_set.filter(headline__contains='Lennon')
>>> b.entry_set.count()

[相关链接](http://blog.csdn.net/hackerain/article/details/39838559

上一篇下一篇

猜你喜欢

热点阅读