From 0ea01101c3a35568bc43e9707ac058b9874bd425 Mon Sep 17 00:00:00 2001 From: Kasyap Pentamaraju Date: Thu, 23 Oct 2025 10:17:55 +0530 Subject: [PATCH 1/2] Fixed #36681 -- Removed English pluralization bias from example in docs/topics/i18n/translation.txt. --- AUTHORS | 1 + docs/topics/i18n/translation.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 28169c3e17f3..5acbe272337a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1066,6 +1066,7 @@ answer newbie questions, and generally made Django that much better: Unai Zalakain Valentina Mukhamedzhanova valtron + Varun Kasyap Pentamaraju Vasiliy Stavenko Vasil Vangelovski Vibhu Agarwal diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index 89dd11e0f4a0..560aa476a17a 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -715,7 +715,7 @@ An example: .. code-block:: html+django {% blocktranslate count counter=list|length %} - There is only one {{ name }} object. + There is {{ counter }} {{ name }} object. {% plural %} There are {{ counter }} {{ name }} objects. {% endblocktranslate %} From ea3a71c2d09f8281d8a50ed20e40e1fb13db5cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Ml=C3=A1dek?= Date: Mon, 26 May 2025 18:37:34 +0200 Subject: [PATCH 2/2] Fixed #26434 -- Removed faulty clearing of ordering field when missing from explicit grouping. Co-authored-by: Simon Charette --- django/db/models/sql/query.py | 8 +++++++- tests/aggregation_regress/tests.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 84950d4ec069..8f9349e7ebbf 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -2346,7 +2346,13 @@ def clear_ordering(self, force=False, clear_default=True): query (not even the model's default). """ if not force and ( - self.is_sliced or self.distinct_fields or self.select_for_update + self.is_sliced + or self.distinct_fields + or self.select_for_update + or ( + isinstance(self.group_by, tuple) + and not {*self.order_by, *self.extra_order_by}.issubset(self.group_by) + ) ): return self.order_by = () diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 3e1a6a71f9ea..5f17169dc66f 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -171,6 +171,25 @@ def assertObjectAttrs(self, obj, **kwargs): for attr, value in kwargs.items(): self.assertEqual(getattr(obj, attr), value) + def test_count_preserve_group_by(self): + # new release of the same book + Book.objects.create( + isbn="113235613", + name=self.b4.name, + pages=self.b4.pages, + rating=4.0, + price=Decimal("39.69"), + contact=self.a5, + publisher=self.p3, + pubdate=datetime.date(2018, 11, 3), + ) + qs = Book.objects.values("contact__name", "publisher__name").annotate( + publications=Count("id") + ) + self.assertEqual(qs.count(), Book.objects.count() - 1) + self.assertEqual(qs.order_by("id").count(), Book.objects.count()) + self.assertEqual(qs.extra(order_by=["id"]).count(), Book.objects.count()) + def test_annotation_with_value(self): values = ( Book.objects.filter(