diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-01-27 13:30:29 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-01-27 13:30:29 +0000 |
| commit | 58cd220f51d5e294cb9e67c12a6e9d08523e282f (patch) | |
| tree | c87c968bb69215449924efe57e8b13d70acd4fa3 /docs/ref/models | |
| parent | 8e8d4b5888b73e5c0b2cfc77be4c6d5898546654 (diff) | |
Fixed #7270 -- Added the ability to follow reverse OneToOneFields in select_related(). Thanks to George Vilches, Ben Davis, and Alex Gaynor for their work on various stages of this patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12307 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/models')
| -rw-r--r-- | docs/ref/models/querysets.txt | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 4740d9ca10..db2fa5687c 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -619,17 +619,29 @@ This is also valid:: ...and would also pull in the ``building`` relation. -You can only refer to ``ForeignKey`` relations in the list of fields passed to -``select_related``. You *can* refer to foreign keys that have ``null=True`` -(unlike the default ``select_related()`` call). It's an error to use both a -list of fields and the ``depth`` parameter in the same ``select_related()`` -call, since they are conflicting options. +You can refer to any ``ForeignKey`` or ``OneToOneField`` relation in +the list of fields passed to ``select_related``. Ths includes foreign +keys that have ``null=True`` (unlike the default ``select_related()`` +call). It's an error to use both a list of fields and the ``depth`` +parameter in the same ``select_related()`` call, since they are +conflicting options. .. versionadded:: 1.0 Both the ``depth`` argument and the ability to specify field names in the call to ``select_related()`` are new in Django version 1.0. +.. versionchanged:: 1.2 + +You can also refer to the reverse direction of a ``OneToOneFields`` in +the list of fields passed to ``select_related`` -- that is, you can traverse +a ``OneToOneField`` back to the object on which the field is defined. Instead +of specifying the field name, use the ``related_name`` for the field on the +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)`` @@ -1335,7 +1347,7 @@ extract two field values, where only one is expected:: entries = Entry.objects.filter(blog__in=list(values)) Note the ``list()`` call around the Blog ``QuerySet`` to force execution of - the first query. Without it, a nested query would be executed, because + the first query. Without it, a nested query would be executed, because :ref:`querysets-are-lazy`. gt |
