diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2017-11-12 14:28:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-12 14:28:11 +0100 |
| commit | 2d3cc94284674638c334670903d49565039d77ae (patch) | |
| tree | 45545d9834b930d5a9a6f7292b5a1f1c201b5f87 /docs | |
| parent | 8f8a4d10d34c1fd6104b08efd16c5c377c142865 (diff) | |
Fixed #28781 -- Added QuerySet.values()/values_list() support for union(), difference(), and intersection().
Thanks Tim Graham for the review.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/querysets.txt | 13 | ||||
| -rw-r--r-- | docs/releases/1.11.8.txt | 4 |
2 files changed, 14 insertions, 3 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 4903d61132..2003e1bf17 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -813,10 +813,17 @@ duplicate values, use the ``all=True`` argument. of the type of the first ``QuerySet`` even if the arguments are ``QuerySet``\s of other models. Passing different models works as long as the ``SELECT`` list is the same in all ``QuerySet``\s (at least the types, the names don't matter -as long as the types in the same order). +as long as the types in the same order). In such cases, you must use the column +names from the first ``QuerySet`` in ``QuerySet`` methods applied to the +resulting ``QuerySet``. For example:: -In addition, only ``LIMIT``, ``OFFSET``, ``COUNT(*)``, and ``ORDER BY`` (i.e. -slicing, :meth:`count`, and :meth:`order_by`) are allowed on the resulting + >>> qs1 = Author.objects.values_list('name') + >>> qs2 = Entry.objects.values_list('headline') + >>> qs1.union(qs2).order_by('name') + +In addition, only ``LIMIT``, ``OFFSET``, ``COUNT(*)``, ``ORDER BY``, and +specifying columns (i.e. slicing, :meth:`count`, :meth:`order_by`, and +:meth:`values()`/:meth:`values_list()`) are allowed on the resulting ``QuerySet``. Further, databases place restrictions on what operations are allowed in the combined queries. For example, most databases don't allow ``LIMIT`` or ``OFFSET`` in the combined queries. diff --git a/docs/releases/1.11.8.txt b/docs/releases/1.11.8.txt index dd9fb0c3ce..7e4963f713 100644 --- a/docs/releases/1.11.8.txt +++ b/docs/releases/1.11.8.txt @@ -11,3 +11,7 @@ Bugfixes * Reallowed, following a regression in Django 1.10, ``AuthenticationForm`` to raise the inactive user error when using ``ModelBackend`` (:ticket:`28645`). + +* Added support for ``QuerySet.values()`` and ``values_list()`` for + ``union()``, ``difference()``, and ``intersection()`` queries + (:ticket:`28781`). |
