diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2006-09-25 13:49:01 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2006-09-25 13:49:01 +0000 |
| commit | 0c41869e6ccf779e19032dede71a627c4370b68a (patch) | |
| tree | 06dcb029e3a98afc346c166ce291e6cedf73f936 /django | |
| parent | f6ec6d24ab0d11b8ce3cdc0fbe6bfab5cee6407e (diff) | |
Made ``pk`` a generic expansion for the primary key, rather than just an expansion for __id__exact.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3826 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index 0b85c3f515..eb4b3b63ae 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -712,14 +712,10 @@ def parse_lookup(kwarg_items, opts): # Extract the last elements of the kwarg. # The very-last is the lookup_type (equals, like, etc). # The second-last is the table column on which the lookup_type is - # to be performed. - # The exceptions to this are: - # 1) "pk", which is an implicit id__exact; - # if we find "pk", make the lookup_type "exact', and insert - # a dummy name of None, which we will replace when - # we know which table column to grab as the primary key. - # 2) If there is only one part, or the last part is not a query - # term, assume that the query is an __exact + # to be performed. If this name is 'pk', it will be substituted with + # the name of the primary key. + # If there is only one part, or the last part is not a query + # term, assume that the query is an __exact lookup_type = path.pop() if lookup_type == 'pk': lookup_type = 'exact' @@ -766,7 +762,7 @@ def lookup_inner(path, lookup_type, value, opts, table, column): name = path.pop(0) # Has the primary key been requested? If so, expand it out # to be the name of the current class' primary key - if name is None: + if name is None or name == 'pk': name = current_opts.pk.name # Try to find the name in the fields associated with the current class |
