Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refs #2217 -- Updated DB API docs to discuss filtering using objects …

…rather than IDs. Second attempt - forgot to save before commit last time.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3302 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c431ade5f5a98fca990a3996be7f7707a31df858 1 parent 8818939
Russell Keith-Magee authored July 09, 2006

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

  1. 16  docs/db-api.txt
16  docs/db-api.txt
@@ -1555,11 +1555,17 @@ of ``INSTALLED_APPS`` is to tell Django the entire model domain.
1555 1555
 Queries over related objects
1556 1556
 ----------------------------
1557 1557
 
1558  
-When specifying a query over a related object, you have the option of 
1559  
-
1560  
-    b = Blog.objects.get(id=5)
1561  
-    e1 = Entry.objects.filter()
1562  
-
  1558
+Queries involving related objects follow the same rules as queries involving
  1559
+normal value fields. When specifying the the value for a query to match, you 
  1560
+may use either an object instance itself, or the primary key value for the 
  1561
+object.
  1562
+
  1563
+For example, if you have a Blog object ``b`` with ``id=5``, the following
  1564
+three queries would be identical::
  1565
+     
  1566
+    Entry.objects.filter(blog=b) # Query using object instance
  1567
+    Entry.objects.filter(blog=b.id) # Query using id from instance
  1568
+    Entry.objects.filter(blog=5) # Query using id directly
1563 1569
 
1564 1570
 Deleting objects
1565 1571
 ================

0 notes on commit c431ade

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