diff options
| author | Kasyap Pentamaraju <vpentamaraju@webmd.net> | 2025-10-25 19:23:40 +0530 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-11-13 11:19:05 -0500 |
| commit | 37b5dced864f0d9e1ac2c1e3ca58a947ee850c71 (patch) | |
| tree | f0f3e475ad352ee7aeb4da032b7bc79e6871a370 /docs/topics | |
| parent | 5ae8659cb5beb9e4bea36a1c1b2e443bff4f3873 (diff) | |
[6.0.x] Fixed #36686 -- Clarified Meta.ordering is ignored in GROUP BY queries.
Backport of 7e765a68598b2b798e49bf1f4b431a7bcac085a4 from main.
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/db/aggregation.txt | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/docs/topics/db/aggregation.txt b/docs/topics/db/aggregation.txt index 5383ba5687..ba797c0b68 100644 --- a/docs/topics/db/aggregation.txt +++ b/docs/topics/db/aggregation.txt @@ -627,8 +627,15 @@ fields you also select in a ``values()`` call. You might reasonably ask why Django doesn't remove the extraneous columns for you. The main reason is consistency with ``distinct()`` and other places: Django **never** removes ordering constraints that you have - specified (and we can't change those other methods' behavior, as that - would violate our :doc:`/misc/api-stability` policy). + specified *explicitly with* ``order_by()`` (and we can't change those + other methods' behavior, as that would violate our + :doc:`/misc/api-stability` policy). + +.. admonition:: Default ordering not applied to GROUP BY + + ``GROUP BY`` queries (for example, those using ``.values()`` and + ``.annotate()``) don't use the model's default ordering. + Use ``order_by()`` explicitly when a given order is needed. Aggregating annotations ----------------------- |
