Py学习  »  Django

官方文档的这部分是不是写的有问题?

cumt_ttr • 10 年前 • 3923 次点击  

https://docs.djangoproject.com/en/1.6/topics/db/examples/many_to_one/ 这个官方文档的这部分是不是有问题啊, Reporter是one的一方,Article是many的一方。。。。。。 ======== Querying in the opposite direction:

>>> Reporter.objects.filter(article__pk=1)
[<Reporter: John Smith>]
>>> Reporter.objects.filter(article=1)
[<Reporter: John Smith>]
>>> Reporter.objects.filter(article=a)
[<Reporter: John Smith>]

>>> Reporter.objects.filter(article__headline__startswith='This')
[<Reporter: John Smith>, <Reporter: John Smith>, <Reporter: John Smith>]
>>> Reporter.objects.filter(article__headline__startswith='This').distinct()
[<Reporter: John Smith>]
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/675
 
3923 次点击  
文章 [ 2 ]  |  最新文章 10 年前