mirror of
https://github.com/django/django.git
synced 2025-07-06 02:39:12 +00:00
magic-removal: Fixed section titles in docs/db-api.txt to uncapitalize words, to match our style
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2741 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9b8332f7df
commit
24b8ffe10c
@ -43,7 +43,7 @@ and the following Django sample session::
|
|||||||
>>> Poll.objects.all()
|
>>> Poll.objects.all()
|
||||||
[What's up?, What's your name?]
|
[What's up?, What's your name?]
|
||||||
|
|
||||||
How Queries Work
|
How queries work
|
||||||
================
|
================
|
||||||
|
|
||||||
Querying in Django is based upon the construction and evaluation of Query
|
Querying in Django is based upon the construction and evaluation of Query
|
||||||
@ -62,8 +62,8 @@ you require, it can be evaluated (using iterators, slicing, or one of a range
|
|||||||
of other techniques), yielding an object or list of objects that meet the
|
of other techniques), yielding an object or list of objects that meet the
|
||||||
specifications of the Query Set.
|
specifications of the Query Set.
|
||||||
|
|
||||||
Obtaining an Initial Query Set
|
Obtaining an initial QuerySet
|
||||||
==============================
|
=============================
|
||||||
|
|
||||||
Every model has at least one Manager; by default, the Manager is called
|
Every model has at least one Manager; by default, the Manager is called
|
||||||
``objects``. One of the most important roles of the Manager is as a source
|
``objects``. One of the most important roles of the Manager is as a source
|
||||||
@ -84,8 +84,8 @@ and construction of Managers.
|
|||||||
|
|
||||||
.. _Managers: http://www.djangoproject.com/documentation/model_api/#managers
|
.. _Managers: http://www.djangoproject.com/documentation/model_api/#managers
|
||||||
|
|
||||||
Query Set Refinement
|
QuerySet refinement
|
||||||
====================
|
===================
|
||||||
|
|
||||||
The initial Query Set provided by the Manager describes all objects of a
|
The initial Query Set provided by the Manager describes all objects of a
|
||||||
given type. However, you will usually need to describe a subset of the
|
given type. However, you will usually need to describe a subset of the
|
||||||
@ -304,7 +304,7 @@ See the `OR lookups examples page`_ for more examples.
|
|||||||
.. _OR lookups examples page: http://www.djangoproject.com/documentation/models/or_lookups/
|
.. _OR lookups examples page: http://www.djangoproject.com/documentation/models/or_lookups/
|
||||||
|
|
||||||
QuerySet evaluation
|
QuerySet evaluation
|
||||||
====================
|
===================
|
||||||
|
|
||||||
A Query Set must be evaluated to return the objects that are contained in the
|
A Query Set must be evaluated to return the objects that are contained in the
|
||||||
set. This can be achieved by iteration, slicing, or by specialist function.
|
set. This can be achieved by iteration, slicing, or by specialist function.
|
||||||
@ -338,7 +338,7 @@ However - be warned; this could have a large memory overhead, as Django will
|
|||||||
create an in-memory representation of every element of the list.
|
create an in-memory representation of every element of the list.
|
||||||
|
|
||||||
Caching and QuerySets
|
Caching and QuerySets
|
||||||
======================
|
=====================
|
||||||
|
|
||||||
Each Query Set contains a cache. In a newly created Query Set, this cache
|
Each Query Set contains a cache. In a newly created Query Set, this cache
|
||||||
is unpopulated. When a Query Set is evaluated for the first time, Django
|
is unpopulated. When a Query Set is evaluated for the first time, Django
|
||||||
@ -365,8 +365,8 @@ To avoid this problem, simply save the Query Set and reuse it::
|
|||||||
print [p for p in queryset] # Evaluate the query set
|
print [p for p in queryset] # Evaluate the query set
|
||||||
print [p for p in queryset] # Re-use the cache from the evaluation
|
print [p for p in queryset] # Re-use the cache from the evaluation
|
||||||
|
|
||||||
Specialist Query Set Evaluation
|
Specialist QuerySet evaluation
|
||||||
===============================
|
==============================
|
||||||
|
|
||||||
The following specialist functions can also be used to evaluate a Query Set.
|
The following specialist functions can also be used to evaluate a Query Set.
|
||||||
Unlike iteration or slicing, these methods do not populate the cache; each
|
Unlike iteration or slicing, these methods do not populate the cache; each
|
||||||
@ -450,7 +450,7 @@ to by the relation.
|
|||||||
ManyToManyField Object Set Object Set
|
ManyToManyField Object Set Object Set
|
||||||
=============== ============= =============
|
=============== ============= =============
|
||||||
|
|
||||||
Single Object Descriptor
|
Single object descriptor
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
If the related object is a single object, the descriptor acts
|
If the related object is a single object, the descriptor acts
|
||||||
@ -490,7 +490,7 @@ a descriptor on an instance is accessed, the database will be
|
|||||||
queried, and the result stored. Subsequent attempts to access
|
queried, and the result stored. Subsequent attempts to access
|
||||||
the descriptor on the same instance will use the cached value.
|
the descriptor on the same instance will use the cached value.
|
||||||
|
|
||||||
Object Set Descriptor
|
Object set descriptor
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
An Object Set Descriptor acts just like the Manager - as an initial Query
|
An Object Set Descriptor acts just like the Manager - as an initial Query
|
||||||
@ -543,7 +543,7 @@ Each of these operations on the Object Set Descriptor has immediate effect
|
|||||||
on the database - every add, create and remove is immediately and
|
on the database - every add, create and remove is immediately and
|
||||||
automatically saved to the database.
|
automatically saved to the database.
|
||||||
|
|
||||||
Relationships and Queries
|
Relationships and queries
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
When composing a ``filter`` or ``exclude`` refinement, it may be necessary to
|
When composing a ``filter`` or ``exclude`` refinement, it may be necessary to
|
||||||
@ -563,8 +563,8 @@ example::
|
|||||||
attribute that starts with "eggs". Django automatically composes the joins
|
attribute that starts with "eggs". Django automatically composes the joins
|
||||||
and conditions required for the SQL query.
|
and conditions required for the SQL query.
|
||||||
|
|
||||||
Specialist Query Sets Refinement
|
Specialist QuerySets refinement
|
||||||
================================
|
===============================
|
||||||
|
|
||||||
In addition to ``filter`` and ``exclude()``, Django provides a range of
|
In addition to ``filter`` and ``exclude()``, Django provides a range of
|
||||||
Query Set refinement methods that modify the types of results returned by
|
Query Set refinement methods that modify the types of results returned by
|
||||||
@ -942,4 +942,3 @@ get_FOO_height() and get_FOO_width()
|
|||||||
For every ``ImageField``, the object will have ``get_FOO_height()`` and
|
For every ``ImageField``, the object will have ``get_FOO_height()`` and
|
||||||
``get_FOO_width()`` methods, where ``FOO`` is the name of the field. This
|
``get_FOO_width()`` methods, where ``FOO`` is the name of the field. This
|
||||||
returns the height (or width) of the image, as an integer, in pixels.
|
returns the height (or width) of the image, as an integer, in pixels.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user