Django

Code

Changeset 8232

Show
Ignore:
Timestamp:
08/08/08 11:00:26 (5 months ago)
Author:
mtredinnick
Message:

Fixed #7546 -- Fixed an incorrect example in the docs that was misleading some
people. Patch from Dan Watson.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/db-api.txt

    r8141 r8232  
    17091709``Entry`` is a one-to-many relation). We might be interested in finding blogs 
    17101710that have an entry which has both *"Lennon"* in the headline and was published 
    1711 today. Or we might want to find blogs that have an entry with *"Lennon"* in 
    1712 the headline as well as an entry that was published today. Since there are 
     1711in 2008. Or we might want to find blogs that have an entry with *"Lennon"* in 
     1712the headline as well as an entry that was published in 2008. Since there are 
    17131713multiple entries associated with a single ``Blog``, both of these queries are 
    17141714possible and make sense in some situations. 
     
    17291729That may sound a bit confusing, so hopefully an example will clarify. To 
    17301730select all blogs that contains entries with *"Lennon"* in the headline and 
    1731 were published today, we would write:: 
     1731were published in 2008, we would write:: 
    17321732 
    17331733    Blog.objects.filter(entry__headline__contains='Lennon', 
    1734             entry__pub_date=datetime.date.today()
     1734            entry__pub_date__year=2008
    17351735 
    17361736To select all blogs that contain an entry with *"Lennon"* in the headline 
    1737 **as well as** an entry that was published today, we would write:: 
     1737**as well as** an entry that was published in 2008, we would write:: 
    17381738 
    17391739    Blog.objects.filter(entry__headline__contains='Lennon').filter( 
    1740             entry__pub_date=datetime.date.today()
     1740            entry__pub_date__year=2008
    17411741 
    17421742In this second example, the first filter restricted the queryset to all those