diff options
author | Arthur Koziel <arthur@arthurkoziel.com> | 2010-09-13 00:04:27 +0000 |
---|---|---|
committer | Arthur Koziel <arthur@arthurkoziel.com> | 2010-09-13 00:04:27 +0000 |
commit | dd49269c7db008b2567f50cb03c4d3d9b321daa1 (patch) | |
tree | 326dd25bb045ac016cda7966b43cbdfe1f67d699 /docs/ref/models/querysets.txt | |
parent | c9b188c4ec939abbe48dae5a371276742e64b6b8 (diff) | |
download | django-soc2010/app-loading.tar.gz |
[soc2010/app-loading] merged trunkarchive/soc2010/app-loadingsoc2010/app-loading
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/models/querysets.txt')
-rw-r--r-- | docs/ref/models/querysets.txt | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 56ff6444e4..87680d3e4d 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1,5 +1,3 @@ -.. _ref-models-querysets: - ====================== QuerySet API reference ====================== @@ -7,13 +5,13 @@ QuerySet API reference .. currentmodule:: django.db.models.QuerySet This document describes the details of the ``QuerySet`` API. It builds on the -material presented in the :ref:`model <topics-db-models>` and :ref:`database -query <topics-db-queries>` guides, so you'll probably want to read and +material presented in the :doc:`model </topics/db/models>` and :doc:`database +query </topics/db/queries>` guides, so you'll probably want to read and understand those documents before reading this one. Throughout this reference we'll use the :ref:`example weblog models -<queryset-model-example>` presented in the :ref:`database query guide -<topics-db-queries>`. +<queryset-model-example>` presented in the :doc:`database query guide +</topics/db/queries>`. .. _when-querysets-are-evaluated: @@ -223,8 +221,8 @@ control the name of the annotation:: >>> q[0].number_of_entries 42 -For an in-depth discussion of aggregation, see :ref:`the topic guide on -Aggregation <topics-db-aggregation>`. +For an in-depth discussion of aggregation, see :doc:`the topic guide on +Aggregation </topics/db/aggregation>`. ``order_by(*fields)`` ~~~~~~~~~~~~~~~~~~~~~ @@ -332,8 +330,6 @@ a model which defines a default ordering, or when using ordering was undefined prior to calling ``reverse()``, and will remain undefined afterward). -.. _queryset-distinct: - ``distinct()`` ~~~~~~~~~~~~~~ @@ -367,9 +363,6 @@ query spans multiple tables, it's possible to get duplicate results when a ``values()`` together, be careful when ordering by fields not in the ``values()`` call. - -.. _queryset-values: - ``values(*fields)`` ~~~~~~~~~~~~~~~~~~~ @@ -679,8 +672,6 @@ related object. ``OneToOneFields`` will not be traversed in the reverse direction if you are performing a depth-based ``select_related``. -.. _queryset-extra: - ``extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -712,9 +703,10 @@ of the arguments is required, but you should use at least one of them. greater than Jan. 1, 2006. Django inserts the given SQL snippet directly into the ``SELECT`` - statement, so the resulting SQL of the above example would be:: + statement, so the resulting SQL of the above example would be something + like:: - SELECT blog_entry.*, (pub_date > '2006-01-01') + SELECT blog_entry.*, (pub_date > '2006-01-01') AS is_recent FROM blog_entry; @@ -843,8 +835,6 @@ of the arguments is required, but you should use at least one of them. Entry.objects.extra(where=['headline=%s'], params=['Lennon']) -.. _queryset-defer: - ``defer(*fields)`` ~~~~~~~~~~~~~~~~~~ @@ -870,7 +860,7 @@ deferred field will be retrieved from the database if you access that field You can make multiple calls to ``defer()``. Each call adds new fields to the deferred set:: - # Defers both the body and lede fields. + # Defers both the body and headline fields. Entry.objects.defer("body").filter(rating=5).defer("headline") The order in which fields are added to the deferred set does not matter. Calling ``defer()`` with a field name that has already been deferred is harmless (the field will still be deferred). @@ -930,7 +920,7 @@ immediately; the remainder are deferred. Thus, successive calls to ``only()`` result in only the final fields being considered:: # This will defer all fields except the headline. - Entry.objects.only("body", "lede").only("headline") + Entry.objects.only("body", "rating").only("headline") Since ``defer()`` acts incrementally (adding fields to the deferred list), you can combine calls to ``only()`` and ``defer()`` and things will behave @@ -973,8 +963,6 @@ something *other than* a ``QuerySet``. These methods do not use a cache (see :ref:`caching-and-querysets`). Rather, they query the database each time they're called. -.. _get-kwargs: - ``get(**kwargs)`` ~~~~~~~~~~~~~~~~~ @@ -1143,8 +1131,6 @@ Example:: If you pass ``in_bulk()`` an empty list, you'll get an empty dictionary. -.. _queryset-iterator: - ``iterator()`` ~~~~~~~~~~~~~~ @@ -1216,8 +1202,8 @@ control the name of the aggregation value that is returned:: >>> q = Blog.objects.aggregate(number_of_entries=Count('entry')) {'number_of_entries': 16} -For an in-depth discussion of aggregation, see :ref:`the topic guide on -Aggregation <topics-db-aggregation>`. +For an in-depth discussion of aggregation, see :doc:`the topic guide on +Aggregation </topics/db/aggregation>`. ``exists()`` ~~~~~~~~~~~~ @@ -1277,7 +1263,7 @@ SQL equivalents:: a Django setting. It's possible to configure your MySQL tables to use case-sensitive comparisons, but some trade-offs are involved. For more information about this, see the :ref:`collation section <mysql-collation>` - in the :ref:`databases <ref-databases>` documentation. + in the :doc:`databases </ref/databases>` documentation. .. fieldlookup:: iexact @@ -1570,7 +1556,7 @@ Example:: SQL equivalent:: - SELECT ... WHERE EXTRACT('year' FROM pub_date) = '2005'; + SELECT ... WHERE pub_date BETWEEN '2005-01-01' AND '2005-12-31 23:59:59.999999'; (The exact SQL syntax varies for each database engine.) @@ -1736,7 +1722,7 @@ Aggregation Functions Django provides the following aggregation functions in the ``django.db.models`` module. For details on how to use these aggregate functions, see -:ref:`the topic guide on aggregation <topics-db-aggregation>`. +:doc:`the topic guide on aggregation </topics/db/aggregation>`. ``Avg`` ~~~~~~~ |