1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #163 -- Added 'pk' database API option, which is a shorthand for (primary_key)__exact

git-svn-id: http://code.djangoproject.com/svn/django/trunk@316 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2005-07-26 16:11:43 +00:00
parent f14c98e44c
commit 786c750c40
14 changed files with 68 additions and 42 deletions

View File

@@ -1146,6 +1146,9 @@ def _parse_lookup(kwarg_items, opts, table_count=0):
params.extend(params2)
continue
lookup_list = kwarg.split(LOOKUP_SEPARATOR)
# pk="value" is shorthand for (primary key)__exact="value"
if lookup_list[-1] == 'pk':
lookup_list = lookup_list[:-1] + [opts.pk.name, 'exact']
if len(lookup_list) == 1:
_throw_bad_kwarg_error(kwarg)
lookup_type = lookup_list.pop()