mirror of
https://github.com/django/django.git
synced 2025-06-08 13:09:13 +00:00
[1.10.x] Updated docs/topics/db/queries.txt examples to use print() function.
Backport of 5595db9504ca3fe431f04f853ac8b71edac012c9 from master
This commit is contained in:
parent
052578879d
commit
355917f7c4
@ -763,16 +763,16 @@ For example, repeatedly getting a certain index in a queryset object will query
|
|||||||
the database each time::
|
the database each time::
|
||||||
|
|
||||||
>>> queryset = Entry.objects.all()
|
>>> queryset = Entry.objects.all()
|
||||||
>>> print queryset[5] # Queries the database
|
>>> print(queryset[5]) # Queries the database
|
||||||
>>> print queryset[5] # Queries the database again
|
>>> print(queryset[5]) # Queries the database again
|
||||||
|
|
||||||
However, if the entire queryset has already been evaluated, the cache will be
|
However, if the entire queryset has already been evaluated, the cache will be
|
||||||
checked instead::
|
checked instead::
|
||||||
|
|
||||||
>>> queryset = Entry.objects.all()
|
>>> queryset = Entry.objects.all()
|
||||||
>>> [entry for entry in queryset] # Queries the database
|
>>> [entry for entry in queryset] # Queries the database
|
||||||
>>> print queryset[5] # Uses cache
|
>>> print(queryset[5]) # Uses cache
|
||||||
>>> print queryset[5] # Uses cache
|
>>> print(queryset[5]) # Uses cache
|
||||||
|
|
||||||
Here are some examples of other actions that will result in the entire queryset
|
Here are some examples of other actions that will result in the entire queryset
|
||||||
being evaluated and therefore populate the cache::
|
being evaluated and therefore populate the cache::
|
||||||
|
Loading…
x
Reference in New Issue
Block a user