Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7546 -- Fixed an incorrect example in the docs that was mislea…

…ding some

people. Patch from Dan Watson.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8232 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 169b8894868555345a6fbaa885d7034e8dd1a16e 1 parent 90b6e14
Malcolm Tredinnick authored August 08, 2008

Showing 1 changed file with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. 12  docs/db-api.txt
12  docs/db-api.txt
@@ -1708,8 +1708,8 @@ When you are filtering an object based on a ``ManyToManyField`` or a reverse
1708 1708
 interested in. Consider the ``Blog``/``Entry`` relationship (``Blog`` to
1709 1709
 ``Entry`` is a one-to-many relation). We might be interested in finding blogs
1710 1710
 that 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
  1711
+in 2008. 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 in 2008. Since there are
1713 1713
 multiple entries associated with a single ``Blog``, both of these queries are
1714 1714
 possible and make sense in some situations.
1715 1715
 
@@ -1728,16 +1728,16 @@ earlier ``filter()`` call.
1728 1728
 
1729 1729
 That may sound a bit confusing, so hopefully an example will clarify. To
1730 1730
 select all blogs that contains entries with *"Lennon"* in the headline and
1731  
-were published today, we would write::
  1731
+were published in 2008, we would write::
1732 1732
 
1733 1733
     Blog.objects.filter(entry__headline__contains='Lennon',
1734  
-            entry__pub_date=datetime.date.today())
  1734
+            entry__pub_date__year=2008)
1735 1735
 
1736 1736
 To 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::
1738 1738
 
1739 1739
     Blog.objects.filter(entry__headline__contains='Lennon').filter(
1740  
-            entry__pub_date=datetime.date.today())
  1740
+            entry__pub_date__year=2008)
1741 1741
 
1742 1742
 In this second example, the first filter restricted the queryset to all those
1743 1743
 blogs linked to that particular type of entry. The second filter restricted

0 notes on commit 169b889

Please sign in to comment.
Something went wrong with that request. Please try again.