diff options
| author | Jason Pellerin <jpellerin@gmail.com> | 2006-11-29 20:16:50 +0000 |
|---|---|---|
| committer | Jason Pellerin <jpellerin@gmail.com> | 2006-11-29 20:16:50 +0000 |
| commit | f8217026f9618adb65ab2d517025e87b98ed2fbe (patch) | |
| tree | 2ab846582343dc9b0894b0bdffa3fe04f590365b /docs/db-api.txt | |
| parent | 9a01534370a272e59f2bb64251d1f46218a32516 (diff) | |
[multi-db] Merge trunk to [3850]. Some tests still failing.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@4142 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/db-api.txt')
| -rw-r--r-- | docs/db-api.txt | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt index 7800ff324a..0d1f049601 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -1140,7 +1140,7 @@ The pk lookup shortcut ---------------------- For convenience, Django provides a ``pk`` lookup type, which stands for -"primary_key". This is shorthand for "an exact lookup on the primary-key." +"primary_key". In the example ``Blog`` model, the primary key is the ``id`` field, so these three statements are equivalent:: @@ -1149,6 +1149,14 @@ three statements are equivalent:: Blog.objects.get(id=14) # __exact is implied Blog.objects.get(pk=14) # pk implies id__exact +The use of ``pk`` isn't limited to ``__exact`` queries -- any query term +can be combined with ``pk`` to perform a query on the primary key of a model:: + + # Get blogs entries with id 1, 4 and 7 + Blog.objects.filter(pk__in=[1,4,7]) + # Get all blog entries with id > 14 + Blog.objects.filter(pk__gt=14) + ``pk`` lookups also work across joins. For example, these three statements are equivalent:: |
