diff options
| author | Matthew Wilkes <git@matthewwilkes.name> | 2017-06-18 16:53:40 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-02-10 19:08:55 -0500 |
| commit | 2162f0983de0dfe2178531638ce7ea56f54dd4e7 (patch) | |
| tree | bb1e859159200fa7ebeeaa02ec3908e1cf5d2655 /docs/howto | |
| parent | bf26f66029bca94b007a2452679ac004598364a6 (diff) | |
Fixed #24747 -- Allowed transforms in QuerySet.order_by() and distinct(*fields).
Diffstat (limited to 'docs/howto')
| -rw-r--r-- | docs/howto/custom-lookups.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/howto/custom-lookups.txt b/docs/howto/custom-lookups.txt index 32037a29aa..55fdc42237 100644 --- a/docs/howto/custom-lookups.txt +++ b/docs/howto/custom-lookups.txt @@ -138,6 +138,21 @@ SQL:: Note that in case there is no other lookup specified, Django interprets ``change__abs=27`` as ``change__abs__exact=27``. +This also allows the result to be used in ``ORDER BY`` and ``DISTINCT ON`` +clauses. For example ``Experiment.objects.order_by('change__abs')`` generates:: + + SELECT ... ORDER BY ABS("experiments"."change") ASC + +And on databases that support distinct on fields (such as PostgreSQL), +``Experiment.objects.distinct('change__abs')`` generates:: + + SELECT ... DISTINCT ON ABS("experiments"."change") + +.. versionchanged:: 2.1 + + Ordering and distinct support as described in the last two paragraphs was + added. + When looking for which lookups are allowable after the ``Transform`` has been applied, Django uses the ``output_field`` attribute. We didn't need to specify this here as it didn't change, but supposing we were applying ``AbsoluteValue`` |
