mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
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
This commit is contained in:
parent
f6ec6d24ab
commit
0c41869e6c
4 changed files with 22 additions and 10 deletions
|
@ -86,6 +86,10 @@ DoesNotExist: Article matching query does not exist.
|
|||
>>> Article.objects.get(pk=1)
|
||||
<Article: Area woman programs in Python>
|
||||
|
||||
# pk can be used as a shortcut for the primary key name in any query
|
||||
>>> Article.objects.filter(pk__in=[1])
|
||||
[<Article: Area woman programs in Python>]
|
||||
|
||||
# Model instances of the same type and same ID are considered equal.
|
||||
>>> a = Article.objects.get(pk=1)
|
||||
>>> b = Article.objects.get(pk=1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue