mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
magic-removal: Fixed #1186 -- Fixed problem resolving primary key in some 'pk' database queries. Also lightly refactored query-parsing code. Thanks, Russ
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1856 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -66,10 +66,23 @@ DoesNotExist: Restaurant does not exist for {'place__id__exact': ...}
|
||||
|
||||
>>> Restaurant.objects.get_object(place__id__exact=1)
|
||||
Demon Dogs the restaurant
|
||||
>>> Restaurant.objects.get_object(place__name__startswith="Demon")
|
||||
Demon Dogs the restaurant
|
||||
>>> Restaurant.objects.get_object(pk=1)
|
||||
Demon Dogs the restaurant
|
||||
>>> Restaurant.objects.get_object(place__exact=1)
|
||||
Demon Dogs the restaurant
|
||||
>>> Restaurant.objects.get_object(place__pk=1)
|
||||
Demon Dogs the restaurant
|
||||
>>> Restaurant.objects.get_object(place__name__startswith="Demon")
|
||||
Demon Dogs the restaurant
|
||||
|
||||
>>> Place.objects.get_object(id__exact=1)
|
||||
Demon Dogs the place
|
||||
>>> Place.objects.get_object(pk=1)
|
||||
Demon Dogs the place
|
||||
>>> Place.objects.get_object(restaurants__place__exact=1)
|
||||
Demon Dogs the place
|
||||
>>> Place.objects.get_object(restaurants__pk=1)
|
||||
Demon Dogs the place
|
||||
|
||||
# Add a Waiter to the Restaurant.
|
||||
>>> w = r.add_waiter(name='Joe')
|
||||
@@ -77,6 +90,17 @@ Demon Dogs the restaurant
|
||||
>>> w
|
||||
Joe the waiter at Demon Dogs the restaurant
|
||||
|
||||
# Query the waiters
|
||||
>>> Waiter.objects.get_list(restaurant__place__exact=1)
|
||||
[Joe the waiter at Demon Dogs the restaurant]
|
||||
>>> Waiter.objects.get_list(restaurant__pk=1)
|
||||
[Joe the waiter at Demon Dogs the restaurant]
|
||||
>>> Waiter.objects.get_list(id__exact=1)
|
||||
[Joe the waiter at Demon Dogs the restaurant]
|
||||
>>> Waiter.objects.get_list(pk=1)
|
||||
[Joe the waiter at Demon Dogs the restaurant]
|
||||
|
||||
# Delete the restaurant; the waiter should also be removed
|
||||
>>> r = Restaurant.objects.get_object(pk=1)
|
||||
>>> r.delete()
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user