diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2006-07-09 03:53:11 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2006-07-09 03:53:11 +0000 |
| commit | c431ade5f5a98fca990a3996be7f7707a31df858 (patch) | |
| tree | afb381040b650b5de9af0f55f8d65cb13c6179aa /docs | |
| parent | 88189399b18282ea16135ed7572f06c57476227c (diff) | |
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
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/db-api.txt | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt index 64f3438014..ce6bb0ab3b 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -1555,11 +1555,17 @@ of ``INSTALLED_APPS`` is to tell Django the entire model domain. Queries over related objects ---------------------------- -When specifying a query over a related object, you have the option of - - b = Blog.objects.get(id=5) - e1 = Entry.objects.filter() +Queries involving related objects follow the same rules as queries involving +normal value fields. When specifying the the value for a query to match, you +may use either an object instance itself, or the primary key value for the +object. +For example, if you have a Blog object ``b`` with ``id=5``, the following +three queries would be identical:: + + Entry.objects.filter(blog=b) # Query using object instance + Entry.objects.filter(blog=b.id) # Query using id from instance + Entry.objects.filter(blog=5) # Query using id directly Deleting objects ================ |
