14300 Commits

Author SHA1 Message Date
JaeHyuck Sa
7c54fee776 Fixed #36246 -- Caught GDALException in BaseGeometryWidget.deserialize.
Signed-off-by: JaeHyuck Sa <wogur981208@gmail.com>
2026-02-06 16:19:49 -05:00
Nilesh Kumar Pahari
6380e3f01e Fixed #36644 -- Enabled empty order_by() to avoid pk ordering by first()/last(). 2026-02-06 15:45:45 -05:00
Nilesh Kumar Pahari
087bb9e8f3 Refs #36644 -- Applied default ordering after union(). 2026-02-06 15:45:45 -05:00
Nick Pope
6f8b2d1c6d Refs #33579 -- Added extra tests for NotUpdated exception.
When `NotUpdated` was added in ab148c02ce,
these additional tests that have equivalents for the `DoesNotExist` and
`MultipleObjectsReturned` exceptions were missed.
2026-02-05 09:18:55 -05:00
Jacob Walls
005d60d97c Refs CVE-2026-1312 -- Raised ValueError when FilteredRelation aliases contain periods.
This prevents failures at the database layer, given that aliases in the
ON clause are not quoted.

Systematically quoting aliases even in FilteredRelation is tracked in
https://code.djangoproject.com/ticket/36795.
2026-02-03 07:56:04 -05:00
Jacob Walls
69065ca869 Fixed CVE-2026-1312 -- Protected order_by() from SQL injection via aliases with periods.
Before, `order_by()` treated a period in a field name as a sign that it
was requested via `.extra(order_by=...)` and thus should be passed
through as raw table and column names, even if `extra()` was not used.
Since periods are permitted in aliases, this meant user-controlled
aliases could force the `order_by()` clause to resolve to a raw table
and column pair instead of the actual target field for the alias.

In practice, only `FilteredRelation` was affected, as the other
expressions we tested, e.g. `F`, aggressively optimize away the ordering
expressions into ordinal positions, e.g. ORDER BY 2, instead of ORDER BY
"table".column.

Thanks Solomon Kebede for the report, and Simon Charette and Jake Howard
for reviews.
2026-02-03 07:55:33 -05:00
Jake Howard
e891a84c7e Fixed CVE-2026-1287 -- Protected against SQL injection in column aliases via control characters.
Control characters in FilteredRelation column aliases could be used for
SQL injection attacks. This affected QuerySet.annotate(), aggregate(),
extra(), values(), values_list(), and alias() when using dictionary
expansion with **kwargs.

Thanks Solomon Kebede for the report, and Simon Charette, Jacob Walls,
and Natalia Bidart for reviews.
2026-02-03 07:55:04 -05:00
Natalia
a33540b3e2 Fixed CVE-2026-1285 -- Mitigated potential DoS in django.utils.text.Truncator for HTML input.
The `TruncateHTMLParser` used `deque.remove()` to remove tags from the
stack when processing end tags. With crafted input containing many
unmatched end tags, this caused repeated full scans of the tag stack,
leading to quadratic time complexity.

The fix uses LIFO semantics, only removing a tag from the stack when it
matches the most recently opened tag. This avoids linear scans for
unmatched end tags and reduces complexity to linear time.

Refs #30686 and 6ee37ada32.

Thanks Seokchan Yoon for the report, and Jake Howard and Jacob Walls for
reviews.
2026-02-03 07:54:16 -05:00
Jacob Walls
81aa529296 Fixed CVE-2026-1207 -- Prevented SQL injections in RasterField lookups via band index.
Thanks Tarek Nakkouch for the report, and Simon Charette for the initial
triage and review.
2026-02-03 07:53:50 -05:00
Jake Howard
eb22e1d6d6 Fixed CVE-2025-14550 -- Optimized repeated header parsing in ASGI requests.
Thanks Jiyong Yang for the report, and Natalia Bidart, Jacob Walls, and
Shai Berger for reviews.
2026-02-03 07:53:12 -05:00
Jake Howard
3eb814e02a Fixed CVE-2025-13473 -- Standardized timing of check_password() in mod_wsgi auth handler.
Refs CVE-2024-39329, #20760.

Thanks Stackered for the report, and Jacob Walls and Markus Holtermann
for the reviews.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2026-02-03 07:52:25 -05:00
ar3ph
72ae25a9c2 Fixed #36879 -- Identified Django client in Redis client metadata. 2026-02-03 06:40:29 -05:00
Jacob Walls
24a14860ce Fixed line length in admin_views test_prepopulated_fields(). 2026-02-02 22:22:04 -05:00
SnippyCodes
1d4c52c8bf Fixed #36893 -- Serialized elidable kwarg for RunSQL and RunPython operations. 2026-02-02 21:05:44 -05:00
Patryk Bratkowski
5798f4bb17 Fixed selenium tests in Firefox.
Unlike Chromium-based browsers, Firefox does not automatically scroll
elements into view when using the Actions API with move_to_element.
This calls the scrollIntoView function explicitly, which fixes
some selenium tests when not running in headless mode.
2026-02-02 14:53:30 -05:00
Jacob Walls
b665a67d61 Fixed #36788 -- Fixed horizontal form field alignment under <fieldset> in the admin.
Thanks Antoliny for the review.

Regression in 4187da258f.
2026-02-02 08:15:13 -05:00
Jacob Walls
674eda1c03 Refs #36865 -- Fixed test_exact_lookup_validates_each_field_independently() crash on databases that don't support primitives in JSONFields.
For example on Oracle < 21c.
2026-01-31 11:48:59 -05:00
Tim Graham
bb8c14b466 Added supports_expression_indexes skip to nulls_distinct test. 2026-01-31 16:26:27 +01:00
Jacob Walls
4a52533329 Refs #34118 -- Removed asgiref coroutine detection shims.
As Python 3.12 is now the floor, we can drop the shims and
use the `inspect` module.
2026-01-31 08:59:54 -05:00
Mark Niehues
08a0b92329 Fixed #36468 -- Fixed failure to close popup when adding a related object in the admin.
The issue manifested when there were multiple relations and only some
of them participated in a filter_horizontal.

Regression in cd0479ff76.
2026-01-30 14:07:16 -05:00
mlissner
4cecf30395 Fixed #36865 -- Removed casting from exact lookups in admin searches.
Instead of casting non-text fields to CharField (which prevents index
usage), skip exact lookups when the search term fails
formfield.to_python().

This preserves index usage for valid searches while gracefully handling
invalid search terms by simply not including them in the query for that
field.

For multi-term searches like 'foo 123' on search_fields=['name', 'age__exact']:
- 'foo': invalid for age, so only name lookup is used
- '123': valid for both, so both lookups are used

This entails a slight increase in permissiveness for search terms that
can be normalized by formfield.to_python().
2026-01-30 11:45:39 -05:00
mlissner
b25bc24418 Refs #36865 -- Added test for invalid value handling in admin changelist. 2026-01-30 11:45:39 -05:00
Nilesh Kumar Pahari
fe189dc43a Fixed #36847 -- Ensured auto_now_add fields are set on pre_save().
Regression in 94680437a4. Refs #27222.

During INSERT operations, `field.pre_save()` is called to prepare values
for db insertion. The `add` param must be `True` for `auto_now_add`
fields to be populated. The regression commit passed `False`, causing
`auto_now_add` fields to remain `None` when used by other fields, such
as `upload_to` callables.

Thanks Ran Benita for the report.
2026-01-29 10:11:33 -03:00
Samriddha9619
2831eaed79 Fixed #36233 -- Avoided quantizing integers stored in DecimalField on SQLite.
Co-authored-by: Simon Charette <charette.s@gmail.com>
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
2026-01-28 17:04:39 -05:00
Markus Holtermann
83622b824b Fixed #36878 -- Unified data type for *_together options in ModelState.
Ever since the beginning of Django's migration framework, there's been a
bit of an inconsistency on how index_together and unique_together values
have been stored on the ModelState[^1].

It's only really obvious, when looking at the current code for
`from_model()`[^2] and the `rename_field()` state alteration code[^3].

The problem in the autodetector's detection of the `*_together` options
as raised in the ticket, reinforces the inconsistency[^4]: the old value
is being normalized to a set of tuples, whereas the new value is taken
as-is.

Why this hasn't been caught before, is likely to the fact, that we
never really look at a `to_state` that comes from migration operations
in the autodetector. Instead, in both usages in Django[^5], [^6] the
`to_state` is a `ProjectState.from_apps()`. And that state is
consistently using sets of tuples and not lists of lists.

[^1]: 67dcea711e (diff-5dd147e9e978e645313dd99eab3a7bab1f1cb0a53e256843adb68aeed71e61dcR85-R87)
[^2]: b1ffa9a9d7/django/db/migrations/state.py (L842)
[^3]: b1ffa9a9d7/django/db/migrations/state.py (L340-L345)
[^4]: b1ffa9a9d7/django/db/migrations/autodetector.py (L1757-L1771)
[^5]: 2351c1b12c/django/core/management/commands/makemigrations.py (L215-L219)
[^6]: 2351c1b12c/django/core/management/commands/migrate.py (L329-L332)
2026-01-28 16:13:05 -05:00
Tim Graham
5d5f95da40 Refs #35744 -- Removed problematic __in lookup in test_intersection_in_nested_subquery.
It's problematic on MongoDB. Simon: "It seems odd that we'd use
__in=OuterRef("pk") over __in=[OuterRef("pk")]. It's a SQLism that
only works because right-hand-side is wrapped with (...) and that's
interpreted as a singleton tuple which is allowed with IN."
2026-01-27 20:18:50 -05:00
jafarkhan83
2e83eb5e78 Fixed #36776 -- Clarified dev server runs in WSGI mode. 2026-01-26 10:45:40 -05:00
varunkasyap
229d026207 Fixed #36883 -- Split monolithic aggregation regression tests. 2026-01-26 10:37:11 -05:00
Nilesh Kumar Pahari
e92d1e3b78 Fixed #36850 -- Prevented admin filter sidebar from wrapping below the changelist.
Removed flex-wrap from .changelist-form-container and added min-width to the
main content container to ensure proper layout behavior.
Regression in 6ea3319079.
2026-01-26 10:25:47 -05:00
Skyiesac
c3c9f1908e Fixed #36812 -- Dropped support for MariaDB < 10.11. 2026-01-25 09:19:43 +01:00
Jacob Walls
68d110f1fe Refs #33735 -- Coped with stacklevel change in ASGITest.test_file_response().
Follow-up to c042fe3a74.

The original ignore was added in 0bd2c0c901
but was not adjusted when the stacklevel changed.
2026-01-23 13:16:30 -05:00
seanhelvey
b1ffa9a9d7 Fixed #13883 -- Rendered named choice groups with <optgroup> in FilteredSelectMultiple.
This patch adds support for <optgroup>s in FilteredSelectMultiple widgets.
When a popup returns a new object, if the source field contains optgroup
choices, the optgroup is now also included in the response data.

Additionally, this adds error handling for invalid source_model parameters
to prevent crashes and display user-friendly error messages instead.

Co-authored-by: Michael McLarnon <mmclar@gmail.com>
2026-01-22 21:12:23 -05:00
Jacob Walls
3851601b2e Refs #36382 -- Fixed GDAL_VERSION comparison in gdal_tests.
Tests regression in 0d31ca9883.
2026-01-20 11:54:07 -05:00
VIZZARD-X
e083c62f51 Fixed #36030 -- Fixed precision loss in division of Decimal literals on SQLite.
Thanks Bob Kline for the review.
2026-01-20 10:42:28 -05:00
Skyiesac
748c2ba837 Refs #36639 -- Updated test migrations to match models. 2026-01-20 10:40:53 -05:00
Mariusz Felisiak
6cff020787 Applied Black's 2026 stable style.
https://github.com/psf/black/releases/tag/26.1.0
2026-01-18 21:26:56 +01:00
David Smith
0d31ca9883 Refs #36382 -- Updated GDAL tests for Memory driver deprecation in GDAL 3.11.
Follow up to fb0d463b1f

Since GDAL 3.11 the Memory driver is deprecated with its functionality
merged into the MEM dataset driver.

https://gdal.org/en/stable/drivers/vector/memory.html
2026-01-16 12:38:21 -05:00
JaeHyuck Sa
0239e86f38 Fixed #36352 -- Improved error message for fields excluded by prior values()/values_list() calls.
Signed-off-by: JaeHyuck Sa <wogur981208@gmail.com>
2026-01-16 10:28:14 -05:00
JaeHyuck Sa
211b631427 Fixed #36822 -- Added parameter limit for PostgreSQL with server-side binding. 2026-01-16 09:15:53 -05:00
JaeHyuck Sa
b98075dc62 Refs #36822 -- Hoisted bulk_batch_size() implementations to base backend. 2026-01-16 09:15:53 -05:00
Jacob Walls
a876ada18b Bumped linter versions in requirements files and tox.ini.
Follow-up to 64ac4385c7.
2026-01-14 15:07:10 -05:00
JaeHyuck Sa
4ce4ed72a4 Fixed #36821 -- Treated empty strings as NULL for iexact lookups on Oracle.
Signed-off-by: JaeHyuck Sa <wogur981208@gmail.com>
2026-01-14 13:31:15 -05:00
Jacob Walls
6a596373d4 Fixed #35402 -- Fixed crash in DatabaseFeatures.django_test_skips when running a subset of tests.
Thanks Tim Graham for the report and the review.
2026-01-14 08:25:37 -05:00
Samriddha9619
040bb3eba7 Fixed #35442 -- Prevented N+1 queries in RelatedManager with only().
Co-authored-by: Simon Charette <charette.s@gmail.com>
2026-01-13 13:18:14 -05:00
Jacob Walls
73c5e94521 Refs #36769 -- Raised SuspiciousOperation for unexpected nested tags in XML Deserializer.
Thanks Shai Berger and Natalia Bidart for reviews.
2026-01-12 16:38:32 -05:00
Jacob Walls
a25158f5cc Refs #36769 -- Avoided visiting grandchild nodes in XML Deserializer.
The only use case for visiting grandchild nodes turned out to be to
support an unintentionally invalid fixture in the test suite.

The invalid fixture added in #36969 was modeled on fixture9.xml in
dae08cf55b, so that is corrected as well
in this commit, where the test will still pass.
2026-01-12 16:38:32 -05:00
Jacob Walls
1a70889d58 Refs #36769 -- Corrected invalid XML fixtures.
fixture9.xml was likely wrong since its introduction in
35cc439228.

The relevant part of the Visa model is:

class Visa(models.Model):
    person = models.ForeignKey(Person, models.CASCADE)

The Visa.person <field>s needed to be declared as relations, and
the Person <field>s didn't need their values wrapped in `<natural>`,
since they weren't relations.
2026-01-12 16:38:32 -05:00
Rudraksha Dwivedi
21ceaf2fd7 Fixed #36708 -- Initialized formset to None in ChangeList.__init__().
Thanks Antoliny for the review.
2026-01-12 13:34:14 -05:00
Parth Paradkar
eeea8d2cba Fixed #36804 -- Fixed admin system check crash for missing models. 2026-01-12 08:46:22 -05:00
Haki Benita
d61838761f Fixed #36827 -- Added support for exclusion constraints using Hash indexes on PostgreSQL. 2026-01-10 08:12:05 +01:00