Ticket #11800: 11800.diff

File 11800.diff, 7.1 KB (added by Tim Graham, 14 years ago)
  • docs/topics/db/optimization.txt

     
    101101
    102102When you have a lot of objects, the caching behaviour of the ``QuerySet`` can
    103103cause 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.
    105105
    106106Do database work in the database rather than in Python
    107107======================================================
     
    122122Use ``QuerySet.extra()``
    123123------------------------
    124124
    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:
     125A less portable but more powerful method is
     126:meth:`~django.db.models.QuerySet.extra()`, which allows some SQL to be
     127explicitly added to the query. If that still isn't powerful enough:
    128128
    129129Use raw SQL
    130130-----------
     
    160160-----------------------------------------------
    161161
    162162When 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>`.
     163appropriate usage of :meth:`~django.db.models.QuerySet.values()`.
    164164These can be useful for replacing model objects in template code - as long as
    165165the dicts you supply have the same attributes as those used in the template, you
    166166are fine.
     
    168168Use ``QuerySet.defer()`` and ``only()``
    169169---------------------------------------
    170170
    171 Use :ref:`defer() and only() <queryset-defer>` if there are database columns you
     171Use :meth:`~django.db.models.QuerySet.defer()` and
     172:meth:`~django.db.models.QuerySet.only()` if there are database columns you
    172173know that you won't need (or won't need in most cases) to avoid loading
    173174them. Note that if you *do* use them, the ORM will have to go and get them in a
    174175separate query, making this a pessimization if you use it inappropriately.
  • docs/topics/db/aggregation.txt

     
    353353query.
    354354
    355355This 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:
    357357normally you won't want extra columns playing a part in the result, so clear
    358358out the ordering, or at least make sure it's restricted only to those fields
    359359you also select in a ``values()`` call.
  • docs/topics/db/sql.txt

     
    116116
    117117    >>> people = Person.objects.raw('SELECT id, first_name FROM myapp_person')
    118118
    119 The ``Person`` objects returned by this query will be :ref:`deferred
    120 <queryset-defer>` model instances. This means that the fields that are omitted
    121 from the query will be loaded on demand. For example::
     119The ``Person`` objects returned by this query will be deferred model instances
     120(see :meth:`~django.db.models.QuerySet.defer()`). This means that the fields
     121that are omitted from the query will be loaded on demand. For example::
    122122
    123123    >>> for p in Person.objects.raw('SELECT id, first_name FROM myapp_person'):
    124124    ...     print p.first_name, # This will be retrieved by the original query
  • docs/releases/1.1-beta-1.txt

     
    7171particular fields, you can now tell Django not to retrieve them from the
    7272database.
    7373
    74 You'll do this with the :ref:`new queryset methods <queryset-defer>`
    75 ``defer()`` and ``only()``.
     74You'll do this with the new queryset methods
     75:meth:`~django.db.models.QuerySet.defer` and
     76:meth:`~django.db.models.QuerySet.only`.
    7677
    7778New admin features
    7879------------------
  • docs/releases/1.1.txt

     
    258258particular fields, you can now tell Django not to retrieve them from the
    259259database.
    260260
    261 You'll do this with the :ref:`new queryset methods <queryset-defer>`
    262 ``defer()`` and ``only()``.
     261You'll do this with the new queryset methods
     262:meth:`~django.db.models.QuerySet.defer` and
     263:meth:`~django.db.models.QuerySet.only`.
    263264
    264265Testing improvements
    265266--------------------
  • docs/ref/models/querysets.txt

     
    332332ordering was undefined prior to calling ``reverse()``, and will remain
    333333undefined afterward).
    334334
    335 .. _queryset-distinct:
    336 
    337335``distinct()``
    338336~~~~~~~~~~~~~~
    339337
     
    367365    ``values()`` together, be careful when ordering by fields not in the
    368366    ``values()`` call.
    369367
    370 
    371 .. _queryset-values:
    372 
    373368``values(*fields)``
    374369~~~~~~~~~~~~~~~~~~~
    375370
     
    679674``OneToOneFields`` will not be traversed in the reverse direction if you
    680675are performing a depth-based ``select_related``.
    681676
    682 .. _queryset-extra:
    683 
    684677``extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)``
    685678~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    686679
     
    843836
    844837        Entry.objects.extra(where=['headline=%s'], params=['Lennon'])
    845838
    846 .. _queryset-defer:
    847 
    848839``defer(*fields)``
    849840~~~~~~~~~~~~~~~~~~
    850841
     
    11431134
    11441135If you pass ``in_bulk()`` an empty list, you'll get an empty dictionary.
    11451136
    1146 .. _queryset-iterator:
    1147 
    11481137``iterator()``
    11491138~~~~~~~~~~~~~~
    11501139
  • docs/ref/contrib/admin/index.txt

     
    474474
    475475.. attribute:: ModelAdmin.list_select_related
    476476
    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.
     477Set ``list_select_related`` to tell Django to use
     478:meth:`~django.db.models.QuerySet.select_related` in retrieving the list of
     479objects on the admin change list page. This can save you a bunch of database
     480queries.
    480481
    481482The value should be either ``True`` or ``False``. Default is ``False``.
    482483
    483 Note that Django will use ``select_related()``, regardless of this setting,
    484 if one of the ``list_display`` fields is a ``ForeignKey``.
     484Note that Django will use :meth:`~django.db.models.QuerySet.select_related`,
     485regardless of this setting, if one of the ``list_display`` fields is a
     486``ForeignKey``.
    485487
    486 For more on ``select_related()``, see
    487 :ref:`the select_related() docs <select-related>`.
    488 
    489488.. attribute:: ModelAdmin.inlines
    490489
    491490See ``InlineModelAdmin`` objects below.
Back to Top