1
0
mirror of https://github.com/django/django.git synced 2025-08-23 10:19:13 +00:00

14042 Commits

Author SHA1 Message Date
Mariusz Felisiak
dd133054cb
Refs #36052, #32234 -- Fixed inspectdb tests for CompositePrimaryKey on Oracle.
Tests regression in 4c75858135589f3a00e32eb4d476074536371a32.
2025-05-06 08:20:56 +02:00
신우진
1fb3f57e81 Fixed #36281 -- Used async-safe write in ASGIHandler.read_body().
Thanks Carlton Gibson for reviews.
2025-05-04 14:53:08 +02:00
Baptiste Mispelon
66f9eb0ff1 Fixed #36357 -- Skipped unique_together in inspectdb output for composite primary keys.
Thanks to Baptiste Mispelon for the report and quick fix, and to Simon
Charette and Jacob Walls for the reviews.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2025-04-30 11:55:25 -03:00
Simon Charette
07100db6f4 Fixed #36358 -- Corrected introspection of composite primary keys on SQLite.
Previously, any first field of a composite primary key with type
`INTEGER` was incorrectly introspected as an `AutoField` due to SQLite
treating `INTEGER PRIMARY KEY` as an alias for the `ROWID`.

This change ensures that integer fields in composite PKs are not
mistaken for auto-incrementing fields.

Thanks Jacob Walls and Sarah Boyce for the reviews.
2025-04-30 10:51:48 -03:00
Simon Charette
4c75858135 Refs #36052, #32234 -- Removed create_test_table_with_composite_primary_key flag in favor of using CompositePrimaryKey.
Now that Django properly supports creating models with composite primary
keys, the tests should use a `CompositePrimaryKey` field instead of a
feature flag to inline backend specific SQL for creating a composite PK.

Specifcially, the inspectdb's test_composite_primary_key was adjusted to
use schema editor instead of per-backend raw SQL.
2025-04-30 10:51:48 -03:00
Simon Charette
8ef4e0bd42 Fixed #36360 -- Fixed QuerySet.update() crash when referring annotations through values().
The issue was only manifesting itself when also filtering againt a related
model as that forces the usage of a subquery because SQLUpdateCompiler doesn't
support the UPDATE FROM syntax yet.

Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a.

Refs #28900.

Thanks Gav O'Connor for the detailed report.
2025-04-30 10:38:19 +01:00
Simon Charette
27ffccc96b Used bulk_create where possible in update tests.
This shaves off 21 INSERT queries.

Thanks Clifford for the review.
2025-04-30 10:38:19 +01:00
Baptiste Mispelon
2722cb61cc Used addCleanup() instead of try-finally blocks in inspectdb tests. 2025-04-29 13:45:05 -03:00
Bruno Alla
bc21bc4282 Fixed #18296 -- Created missing custom target directory for startproject and startapp. 2025-04-27 14:41:27 +01:00
sag​e
fb427e467c
Fixed aggregation tests crash on databases that don't support JSONFields. 2025-04-27 09:03:35 +02:00
nessita
0596263c31
Fixed #36309 -- Made email alternatives and attachments pickleable.
Regression in aba0e541caaa086f183197eaaca0ac20a730bbe4 and in
d5bebc1c26d4c0ec9eaa057aefc5b38649c0ba3b.

Thanks Florent Messa for the report, and Jake Howard and Claude
Paroz for the review.
2025-04-24 10:11:16 -03:00
Matti Pohjanvirta
1e9db35836 Fixed #36341 -- Preserved whitespaces in wordwrap template filter.
Regression in 55d89e25f4115c5674cdd9b9bcba2bb2bb6d820b.

This work improves the django.utils.text.wrap() function to ensure that
empty lines and lines with whitespace only are kept instead of being
dropped.

Thanks Matti Pohjanvirta for the report and fix.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2025-04-23 16:14:03 -03:00
Simon Charette
760121dcb1 Fixed #35801 -- Prevented collision of senders with non-overlapping lifetimes.
As documented, the id() function can return the same value for distinct
objects with non-overlapping lifetimes which can result in signals being
sent to the wrong receivers if two distinct senders happen to have a
colliding id() value.

Since reproduction of the issue requires memory constrained
circumstances where the same exact id() is reused for two senders of the
same signal the test opt to simulate the collision by systematically
making the same id for Sender instances.

Note that we explicitly avoid keeping a strong reference to senders that
cannot be weakly referenced as that would unexpectedly prevent them from
being garbage collected. This means that id(sender) collisions could
still occur for such objects but Django itself doesn't make use of them.

Thanks Sjoerd Job Postmus for the reduced test case and Mariusz for the
review.

Co-authored-by: And Clover <and@doxdesk.com>
2025-04-23 13:09:46 +01:00
antoliny0919
1bc805e23b Fixed #36331 -- Reverted "Fixed #36055 -- Prevented overlap of object-tools buttons and page header in the admin."
This reverts commits b1324a680add78de24c763911d0eefa19b9263bc and
02a5cbfe76382da2a0414df17017185be5bd47f9. The former caused a regression
in admin sites that relied on the `object-tools` block being inside the
`content` block.

Thank you to Fabian Braun for the report.
2025-04-22 22:13:38 -03:00
SaJH
1831f7733d Fixed #36326 -- Added CompositePrimaryKey support in QuerySet.raw().
Signed-off-by: SaJH <wogur981208@gmail.com>
2025-04-17 17:23:06 +02:00
Sarah Boyce
d755a98b84 Fixed #35959 -- Displayed password reset button in admin only when user has sufficient permissions.
This change ensures that the "Reset password" button in the admin is
shown only when the user has the necessary permission to perform a
password change operation. It reuses the password hashing rendering
logic in `display_for_field` to show the appropriate read-only widget
for users with view-only access.
2025-04-17 12:00:20 -03:00
Sarah Boyce
8a0ad1ebe3 Refs #35959 -- Added render_password_as_hash auth template tag for password rendering. 2025-04-17 12:00:20 -03:00
Ahmed Nassar
d469db978e Fixed #36314 -- Fixed MinimumLengthValidator error message translation.
Regression in ec7d69035a408b357f1803ca05a7c991cc358cfa.

Thank you Gabriel Trouvé for the report and Claude Paroz for the review.
2025-04-17 12:30:20 +02:00
farhan
4a293eff6f Fixed #28050 -- Added template name to TemplateSyntaxError. 2025-04-17 08:56:53 +02:00
Adam Johnson
6ef0f5bc27 Americanized some spellings. 2025-04-16 10:21:38 +02:00
Mikuláš Poul
494d2dc316 Fixed #36274 -- Added support for run_before and atomic in MigrationWriter. 2025-04-16 10:20:49 +02:00
Simon Charette
21f8be76d4 Fixed #36288 -- Addressed improper handling of duplicates in values_list().
Now that selected aliases are stored in sql.Query.selected: dict[str, Any]
the values_list() method must ensures that duplicate field name references are
assigned unique aliases.

Refs #28900.

Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a.

Thanks Claude for the report.
2025-04-11 09:04:49 +02:00
Andrew
2d1ac1dce8
Refs #36036 -- Removed unsupported 4D GEOS tests. 2025-04-09 22:40:55 -03:00
Ahmed Nassar
522dd021b2 Fixed #35986 -- Fixed test classes with @translation.override decorator.
Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-04-09 09:49:14 +02:00
Mike Edmunds
a627829e7b Refs #35581 -- Updated mail tests to include trailing newlines.
Python's modern email API will force a trailing newline onto all text/*
bodies and attachments. Updated mail tests to include (and check for)
the newline while still using the legacy email API.

See https://github.com/python/cpython/issues/121515 which reasons that,
apart from artificial test cases, most text content already ends in a
newline. If it doesn't, adding one won't change the meaning.
2025-04-09 09:46:10 +02:00
Simon Charette
71a19a0e47 Fixed #36301 -- Fixed select_for_update(of) crash when using values()/values_list().
Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a which allowed for
annotations to be SELECT'ed before model field references through
values()/values_list() and broke assumptions the select_for_update(of)
table infererence logic had about model fields always being first.

Refs #28900.

Thanks OutOfFocus4 for the report and Sarah for the test.
2025-04-07 22:56:40 +02:00
Sarah Boyce
8ad3e80e88 Fixed #36298 -- Truncated the overwritten file content in file_move_safe().
Regression in 58cd4902a71a3695dd6c21dc957f59c333db364c.

Thanks Baptiste Mispelon for the report.
2025-04-07 16:11:36 +02:00
Mariusz Felisiak
d4a2809c2b
Added supports_expression_defaults check in DefaultTests.test_full_clean() test. 2025-04-06 09:40:12 +02:00
Simon Charette
12b771a1ec Fixed #36299 -- Prevented field selection on QuerySet.alias() after values().
Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a.

Refs #28900.

Thanks Jeff Iadarola for the report and tests.

Co-Authored-By: OutOfFocus4 <jeff.iadarola@gmail.com>
2025-04-05 20:43:50 +02:00
Kelvin Adigwu
25f97e7bcf
Fixed #36156 -- Added supports_json_field check in test_db_default_output_field_resolving test. 2025-04-05 18:54:08 +02:00
Tim Graham
02e7a162a0
Refs #36088, Refs #36260 - Added supports_expression_defaults checks in bulk_create() tests. 2025-04-05 18:47:53 +02:00
Simon Charette
764af7a3d6 Fixed #36289 -- Fixed bulk_create() crash with nullable geometry fields on PostGIS.
Swapped to an allow list instead of a deny list for field types to
determine if the UNNEST optimization can be enabled to avoid further
surprises with other types that would require further specialization to
adapt.

Regression in a16eedcf9c69d8a11d94cac1811018c5b996d491.

Thanks Joshua Goodwin for the report and Sarah Boyce for the test.
2025-04-04 21:33:04 +02:00
koffi
019acad112 Fixed #36255 -- Renamed the admin action button for improved accessibility. 2025-04-04 17:41:13 +02:00
Simon Charette
f7f38f3a0b Fixed #36290 -- Made TupleIn() lookup discard tuples containing None.
Just like the In() lookup discards of None members TupleIn() should
discard tuples containing any None as NULL != NULL in SQL and the
framework expects such queries to be elided under some circumstances.

Refs #31667, #36116.

Thanks Basptise Mispelon for bisecting the regression to 626d77e.
2025-04-03 20:40:43 +02:00
Simon Charette
543e17c440 Fixed #36292 -- Fixed crash when aggregating over a group mixing transforms and references.
Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a.

Refs #28900

Thanks Patrick Altman for the report.
2025-04-03 17:51:26 +02:00
Sarah Boyce
39e2297210 Fixed CVE-2025-27556 -- Mitigated potential DoS in url_has_allowed_host_and_scheme() on Windows.
Thank you sw0rd1ight for the report.
2025-04-02 10:21:33 +02:00
Ahmed Nassar
00c68f03b5 Fixed #36267 -- Fixed contenttypes shortcut() view crash with an invalid object_id for a UUIDField pk. 2025-04-02 09:33:13 +02:00
Jacob Walls
a0fb35eb72 Fixed #36184 -- Allowed migrating forward to squashed migrations. 2025-04-01 09:35:37 +02:00
Anthony Joseph
6888375c53 Fixed #22977 -- Added system check for clashing managers and reverse related fields.
With thanks to  Konrad Świat, Loïc Bistuer, Russell Keith-Magee,
and Mariusz Felisiak.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2025-03-31 22:20:43 +02:00
Song Junho
126417be43 Fixed #36265 -- Added support for serialization of ZoneInfo instances in migrations. 2025-03-31 13:44:54 +02:00
Mariusz Felisiak
281910ff8e
Fixed warnings per flake8 7.2.0.
https://github.com/PyCQA/flake8/releases/tag/7.2.0
2025-03-30 17:54:15 +02:00
saJaeHyukc
c1a4fccf53 Fixed #36239 -- Fixed a crash in ManyToManyField.through_fields check when to model is invalid.
Signed-off-by: saJaeHyukc <wogur981208@gmail.com>
2025-03-28 12:37:57 +01:00
antoliny0919
849f8307a5 Fixed #34917 -- Underlined links in the main content area of the admin. 2025-03-27 13:27:33 +01:00
Khudyakov Artem
9aabe7eae3 Fixed #35440 -- Simplified parse_header_parameters by leveraging stdlid's Message.
The `parse_header_parameters` function historically used Python's `cgi`
module  (now deprecated). In 34e2148fc725e7200050f74130d7523e3cd8507a,
the logic was inlined to work around this deprecation ( #33173). Later,
in d4d5427571b4bf3a21c902276c2a00215c2a37cc, the header parsing logic
was further cleaned up to align with `multipartparser.py` (#33697).

This change takes it a step further by replacing the copied `cgi` logic with
Python's `email.message.Message` API for a more robust and maintainable header
parsing implementation.

Thanks to Raphael Gaschignard for testing, and to Adam Johnson and Shai
Berger for reviews.

Co-authored-by: Ben Cail <bcail@crossway.org>
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2025-03-27 08:57:03 -03:00
Clifford Gama
d5c19f9b32 Fixed #34819 -- Made GenericForeignKey prefetching use matching pk representations.
Ensured that rel_obj_attr and instance_attr return matching (pk, cls) tuples
in GenericForeignKey.get_prefetch_queryset(), preventing mismatches when
prefetching related objects where pk and get_prep_value() differ. Using
value_to_string() also makes this code compatible with composite primary keys.
2025-03-26 09:55:38 +01:00
Dmitry Shachnev
77b4ecbd53 Fixed #36260 -- Made bulk_create() work with DB-generated primary keys.
Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-03-26 09:55:09 +01:00
Giannis Terzopoulos
a39c28706a Fixed #35529 -- Added support for positional arguments in querystring template tag.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2025-03-25 12:23:41 -03:00
Jason Cameron
9608678704 Fixed #36262 -- Made GeneratedField.db_persist a required key-word argument. 2025-03-25 12:50:24 +01:00
wookkl
334677ad57 Fixed #35452 -- Deprecated orphans being more than or equal to page_size in pagination. 2025-03-25 12:04:13 +01:00
Tim Graham
fecca298a2 Fixed #36276 -- Omitted size=None from ArrayField.deconstruct(). 2025-03-25 12:02:14 +01:00