Ticket #11800: 11800.diff
File 11800.diff, 7.1 KB (added by , 14 years ago) |
---|
-
docs/topics/db/optimization.txt
101 101 102 102 When you have a lot of objects, the caching behaviour of the ``QuerySet`` can 103 103 cause a large amount of memory to be used. In this case, 104 : ref:`QuerySet.iterator() <queryset-iterator>` may help.104 :meth:`~django.db.models.QuerySet.iterator()` may help. 105 105 106 106 Do database work in the database rather than in Python 107 107 ====================================================== … … 122 122 Use ``QuerySet.extra()`` 123 123 ------------------------ 124 124 125 A less portable but more powerful method is :ref:`QuerySet.extra()126 <queryset-extra>`, which allows some SQL to be explicitly added to the query. 127 If that still isn't powerful enough:125 A less portable but more powerful method is 126 :meth:`~django.db.models.QuerySet.extra()`, which allows some SQL to be 127 explicitly added to the query. If that still isn't powerful enough: 128 128 129 129 Use raw SQL 130 130 ----------- … … 160 160 ----------------------------------------------- 161 161 162 162 When you just want a dict/list of values, and don't need ORM model objects, make 163 appropriate usage of : ref:`QuerySet.values() <queryset-values>`.163 appropriate usage of :meth:`~django.db.models.QuerySet.values()`. 164 164 These can be useful for replacing model objects in template code - as long as 165 165 the dicts you supply have the same attributes as those used in the template, you 166 166 are fine. … … 168 168 Use ``QuerySet.defer()`` and ``only()`` 169 169 --------------------------------------- 170 170 171 Use :ref:`defer() and only() <queryset-defer>` if there are database columns you 171 Use :meth:`~django.db.models.QuerySet.defer()` and 172 :meth:`~django.db.models.QuerySet.only()` if there are database columns you 172 173 know that you won't need (or won't need in most cases) to avoid loading 173 174 them. Note that if you *do* use them, the ORM will have to go and get them in a 174 175 separate query, making this a pessimization if you use it inappropriately. -
docs/topics/db/aggregation.txt
353 353 query. 354 354 355 355 This behavior is the same as that noted in the queryset documentation for 356 : ref:`distinct() <queryset-distinct>` and the general rule is the same:356 :meth:`~django.db.models.QuerySet.distinct` and the general rule is the same: 357 357 normally you won't want extra columns playing a part in the result, so clear 358 358 out the ordering, or at least make sure it's restricted only to those fields 359 359 you also select in a ``values()`` call. -
docs/topics/db/sql.txt
116 116 117 117 >>> people = Person.objects.raw('SELECT id, first_name FROM myapp_person') 118 118 119 The ``Person`` objects returned by this query will be :ref:`deferred120 <queryset-defer>` model instances. This means that the fields that are omitted 121 from the query will be loaded on demand. For example::119 The ``Person`` objects returned by this query will be deferred model instances 120 (see :meth:`~django.db.models.QuerySet.defer()`). This means that the fields 121 that are omitted from the query will be loaded on demand. For example:: 122 122 123 123 >>> for p in Person.objects.raw('SELECT id, first_name FROM myapp_person'): 124 124 ... print p.first_name, # This will be retrieved by the original query -
docs/releases/1.1-beta-1.txt
71 71 particular fields, you can now tell Django not to retrieve them from the 72 72 database. 73 73 74 You'll do this with the :ref:`new queryset methods <queryset-defer>` 75 ``defer()`` and ``only()``. 74 You'll do this with the new queryset methods 75 :meth:`~django.db.models.QuerySet.defer` and 76 :meth:`~django.db.models.QuerySet.only`. 76 77 77 78 New admin features 78 79 ------------------ -
docs/releases/1.1.txt
258 258 particular fields, you can now tell Django not to retrieve them from the 259 259 database. 260 260 261 You'll do this with the :ref:`new queryset methods <queryset-defer>` 262 ``defer()`` and ``only()``. 261 You'll do this with the new queryset methods 262 :meth:`~django.db.models.QuerySet.defer` and 263 :meth:`~django.db.models.QuerySet.only`. 263 264 264 265 Testing improvements 265 266 -------------------- -
docs/ref/models/querysets.txt
332 332 ordering was undefined prior to calling ``reverse()``, and will remain 333 333 undefined afterward). 334 334 335 .. _queryset-distinct:336 337 335 ``distinct()`` 338 336 ~~~~~~~~~~~~~~ 339 337 … … 367 365 ``values()`` together, be careful when ordering by fields not in the 368 366 ``values()`` call. 369 367 370 371 .. _queryset-values:372 373 368 ``values(*fields)`` 374 369 ~~~~~~~~~~~~~~~~~~~ 375 370 … … 679 674 ``OneToOneFields`` will not be traversed in the reverse direction if you 680 675 are performing a depth-based ``select_related``. 681 676 682 .. _queryset-extra:683 684 677 ``extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)`` 685 678 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 686 679 … … 843 836 844 837 Entry.objects.extra(where=['headline=%s'], params=['Lennon']) 845 838 846 .. _queryset-defer:847 848 839 ``defer(*fields)`` 849 840 ~~~~~~~~~~~~~~~~~~ 850 841 … … 1143 1134 1144 1135 If you pass ``in_bulk()`` an empty list, you'll get an empty dictionary. 1145 1136 1146 .. _queryset-iterator:1147 1148 1137 ``iterator()`` 1149 1138 ~~~~~~~~~~~~~~ 1150 1139 -
docs/ref/contrib/admin/index.txt
474 474 475 475 .. attribute:: ModelAdmin.list_select_related 476 476 477 Set ``list_select_related`` to tell Django to use ``select_related()`` in 478 retrieving the list of objects on the admin change list page. This can save you 479 a bunch of database queries. 477 Set ``list_select_related`` to tell Django to use 478 :meth:`~django.db.models.QuerySet.select_related` in retrieving the list of 479 objects on the admin change list page. This can save you a bunch of database 480 queries. 480 481 481 482 The value should be either ``True`` or ``False``. Default is ``False``. 482 483 483 Note that Django will use ``select_related()``, regardless of this setting, 484 if one of the ``list_display`` fields is a ``ForeignKey``. 484 Note that Django will use :meth:`~django.db.models.QuerySet.select_related`, 485 regardless of this setting, if one of the ``list_display`` fields is a 486 ``ForeignKey``. 485 487 486 For more on ``select_related()``, see487 :ref:`the select_related() docs <select-related>`.488 489 488 .. attribute:: ModelAdmin.inlines 490 489 491 490 See ``InlineModelAdmin`` objects below.