1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00
Commit Graph

13681 Commits

Author SHA1 Message Date
Simon Charette
57307bbc7d Fixed #35666 -- Documented stacklevel usage and testing, and adjusted test suite accordingly.
Over the years we've had multiple instances of hit and misses when
emitting warnings: either setting the wrong stacklevel or not setting
it at all.

This work adds assertions for the existing warnings that were declaring
the correct stacklevel, but were lacking tests for it.
2024-08-28 11:44:05 -03:00
Simon Charette
39abd56a7f Refs #35405 -- Adjusted deprecation warning stacklevel in FieldCacheMixin.get_cache_name(). 2024-08-28 11:44:05 -03:00
Simon Charette
47f18a7226 Refs #35326 -- Adjusted deprecation warning stacklevel in FileSystemStorage.OS_OPEN_FLAGS. 2024-08-28 11:44:05 -03:00
Simon Charette
52ed2b645e Refs #35060 -- Adjusted deprecation warning stacklevel in Model.save()/asave(). 2024-08-28 11:44:05 -03:00
Simon Charette
a69f895d7d Refs #34547 -- Adjusted deprecation warning stacklevel in DatabaseOperations.field_cast_sql(). 2024-08-28 11:44:05 -03:00
Simon Charette
c042fe3a74 Refs #33735 -- Adjusted warning stacklevel in StreamingHttpResponse.__iter__()/__aiter__(). 2024-08-28 11:44:05 -03:00
Simon Charette
7e6e1c8383 Refs #32339 -- Adjusted deprecation warning stacklevel in transitional form renderers. 2024-08-28 11:44:05 -03:00
Simon Charette
6bd5d4f705 Refs #22712 -- Adjusted deprecation warning stacklevel in staticfiles finders. 2024-08-28 11:44:05 -03:00
Simon Charette
8ee17037ae Refs #16055 -- Adjusted deprecation warning stacklevel in get_joining_columns()/get_reverse_joining_columns(). 2024-08-28 11:44:05 -03:00
Simon Charette
5e81a4e790 Refs #12581 -- Adjusted warning stacklevel in queries ring buffer. 2024-08-28 11:44:05 -03:00
Mariusz Felisiak
07a4d23283
Refs #34900 -- Updated requirements for Python 3.13. 2024-08-28 09:02:47 -03:00
Adam Johnson
2b71b2c8dc
Refs #34609 -- Fixed deprecation warning stack level in format_html().
Co-authored-by: Simon Charette <charette.s@gmail.com>
2024-08-27 15:14:50 -03:00
Tim Graham
bc9b6251e0 Added supports_sequence_reset skip in backends tests. 2024-08-26 12:53:08 -03:00
Tim Graham
6a85c888bf Added supports_select_union skips in queries and aggregation tests. 2024-08-26 12:53:08 -03:00
Maarten Breddels
cdcd604ef8 Fixed #35703 -- Made technical_404_response() respect SCRIPT_NAME to return default_urlconf(). 2024-08-23 18:07:47 +02:00
Giovanni Fabbretti
f72bbd4480 Fixed #35689 -- Handled custom labels in LabelCommand.missing_args_message. 2024-08-23 17:26:28 +02:00
nessita
046a354217
Added helper and refactored PasswordResetFormTest to unify email sending tests. 2024-08-23 11:13:31 -03:00
Hisham Mahmood
519087819e
Fixed #35695 -- Ensured FileFields use a storage pointing to a temp directory in model_fields tests. 2024-08-21 08:51:25 -03:00
Sarah Boyce
d9ae7f5b58 Fixed #35686 -- Added table headers to app list tables for screen readers. 2024-08-20 09:05:16 +02:00
nabil-rady
231c0d8593 Fixed #35668 -- Added mapping support to format_html_join. 2024-08-20 08:20:34 +02:00
Natalia
0ebed5fa95 Fixed #35678 -- Removed "usable_password" field from BaseUserCreationForm.
Refs #34429: Following the implementation allowing the setting of
unusable passwords via the admin site, the `BaseUserCreationForm` and
`UserCreationForm` were extended to include a new field for choosing
whether password-based authentication for the new user should be enabled
or disabled at creation time.
Given that these forms are designed to be extended when implementing
custom user models, this branch ensures that this new field is moved to
a new, admin-dedicated, user creation form `AdminUserCreationForm`.

Regression in e626716c28.

Thanks Simon Willison for the report, Fabian Braun and Sarah Boyce for
the review.
2024-08-19 12:39:57 -03:00
Natalia
b60fd8722f Refs #35678 -- Split tests for BaseUserCreationForm when using a custom User model.
This work also allows to subclass BaseUserCreationFormTest to reuse the
tests and assertions for testing forms that extend BaseUserCreationForm,
which is now used for UserCreationFormTest, increasing its coverage.
2024-08-19 12:39:57 -03:00
Mariusz Felisiak
a57596e443 Refs #35658 -- Fixed test_create_file_field_from_another_file_field_in_memory_storage when run in reverse. 2024-08-15 08:52:19 +02:00
Jacob Walls
b99c608ea1 Refs #35402 -- Added tests for invalid usage of submodules in some settings. 2024-08-13 16:09:52 +02:00
Simon Charette
602fe961e6 Fixed #35665 -- Fixed a crash when passing an empty order_by to Window.
This also caused un-ordered sliced prefetches to crash as they rely on Window.

Regression in e16d0c176e that made OrderByList
piggy-back ExpressionList without porting the empty handling that the latter
provided.

Supporting explicit empty ordering on Window functions and slicing is arguably
a foot-gun design due to how backends will return undeterministic results but
this is a problem that requires a larger discussion.

Refs #35064.

Thanks Andrew Backer for the report and Mariusz for the review.
2024-08-13 11:26:17 +02:00
Matthias Kestenholz
d84200e4eb Fixed #35648 -- Raised NotImplementedError in SafeString.__add__ for non-string RHS.
This change ensures SafeString addition operations handle non-string RHS
properly, allowing them to implement __radd__ for better compatibility.
2024-08-12 14:25:05 -03:00
Matthias Kestenholz
b5c048f5ec Refs #35648 -- Added test for addition between SafeString and str in utils_tests. 2024-08-12 14:25:05 -03:00
Devin Cox
e03083917d Fixed #35586 -- Added support for set-returning database functions.
Aggregation optimization didn't account for not referenced set-returning annotations on Postgres.

Co-authored-by: Simon Charette <charette.s@gmail.com>
2024-08-12 15:35:19 +02:00
Mark Gensler
228128618b Fixed #35575 -- Added support for constraint validation on GeneratedFields. 2024-08-12 13:45:57 +02:00
Mariusz Felisiak
f883bef054 Refs #35591 -- Removed hardcoded "stable" version in runserver warning. 2024-08-12 10:57:02 +02:00
lucasesposito
f16a9a556f Fixed #35658 -- Initialized InMemoryFileNode instances with a name. 2024-08-09 12:27:15 +02:00
Andrew Miller
69aa13ffb9 Fixed #35591 -- Added unsuitable for production console warning to runserver. 2024-08-09 10:34:10 +02:00
Adam Johnson
9582745257 Fixed #35622 -- Made unittest ignore Django assertions in traceback frames.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-08-08 21:34:01 -03:00
Natalia
e1606d27b4 Added test for acheck_password() to ensure make_password is called for unusable passwords.
This is a follow up for the fix of CVE-2024-39329
(5d86458579) where the timing of
verify_password() was standardized when checking unusable passwords.
2024-08-08 12:53:36 -03:00
Mariusz Felisiak
7fb15ad5bc Fixed #35661 -- Fixed test_too_many_digits_to_rander() test crash on PyPy.
Thanks Michał Górny for the report.
2024-08-08 09:53:04 +02:00
Matthias Kestenholz
54888408a1
Fixed #35639 -- Improved admin's delete confirmation page title. 2024-08-07 18:10:49 -03:00
Natalia
a05187fce6 Fixed i18n.tests.TranslationTests.test_plural to use correct French translation.
Forwardport of d5ad743e79 from stable/5.1.x.
2024-08-07 10:10:28 -03:00
Farhan
6993c9d8c9 Fixed #35553 -- Handled import*as in HashedFilesMixin. 2024-08-07 11:01:56 +02:00
Simon Charette
c87bfaacf8 Fixed CVE-2024-42005 -- Mitigated QuerySet.values() SQL injection attacks against JSON fields.
Thanks Eyal (eyalgabay) for the report.
2024-08-06 08:50:08 +02:00
Mariusz Felisiak
5f1757142f Fixed CVE-2024-41991 -- Prevented potential ReDoS in django.utils.html.urlize() and AdminURLFieldWidget.
Thanks Seokchan Yoon for the report.

Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-08-06 08:50:08 +02:00
Sarah Boyce
ecf1f8fb90 Fixed CVE-2024-41990 -- Mitigated potential DoS in urlize and urlizetrunc template filters.
Thanks to MProgrammer for the report.
2024-08-06 08:50:08 +02:00
Sarah Boyce
c19465ad87 Fixed CVE-2024-41989 -- Prevented excessive memory consumption in floatformat.
Thanks Elias Myllymäki for the report.

Co-authored-by: Shai Berger <shai@platonix.com>
2024-08-06 08:50:08 +02:00
Sarah Boyce
8deb6bb1fc
Fixed #35657 -- Made FileField handle db_default values. 2024-08-05 16:36:49 -03:00
David Sanders
509763c799 Fixed #35638 -- Updated validate_constraints to consider db_default. 2024-08-05 17:33:12 +02:00
John Parton
7f8d839722 Fixed #35628 -- Allowed compatible GeneratedFields for ModelAdmin.date_hierarchy. 2024-08-05 15:27:20 +02:00
Jake Howard
d5bebc1c26 Refs #35537 -- Improved documentation and test coverage for email attachments and alternatives. 2024-08-05 09:21:44 +02:00
Simon Charette
a16f13a866
Fixed #35643 -- Fixed a crash when ordering a QuerySet by a reference containing "__".
Regression in b0ad41198b.

Refs #34013. The initial logic did not consider that annotation aliases
can include lookup or transform separators.

Thanks Gert Van Gool for the report and Mariusz Felisiak for the review.
2024-08-02 16:21:12 -03:00
lucasesposito
b478cae006 Fixed #35601 -- Added TelInput widget. 2024-08-02 11:31:54 +02:00
arjunomray
946c3cf734 Fixed #35599 -- Added ColorInput widget. 2024-08-02 09:51:49 +02:00
Vaarun Sinha
54e8b4e582 Fixed #35489 -- Fixed vertical alignment of raw_id_fields widget.
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-08-02 08:56:54 +02:00
Markus Holtermann
aa90795050 Fixed #35646 -- Extended SafeExceptionReporterFilter.hidden_settings to treat AUTH as a sensitive match.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-08-01 15:02:00 -03:00
Natalia
615c80aba6 Improved view_tests.tests.test_debug.ExceptionReporterFilterTests. 2024-08-01 15:02:00 -03:00
Bendeguz Csirmaz
1eac690d25 Refs #373 -- Added tuple lookups. 2024-08-01 17:26:09 +02:00
Sarah Boyce
3dac3271d2 Reverted "Fixed #28646 -- Prevented duplicate index when unique is set to True on PostgreSQL."
This reverts commit 9cf9c796be due to a crash on Oracle
as it didn't allow multiple indexes on the same field.
2024-08-01 09:25:33 +02:00
Jeremy Thompson
30a60e8492 Fixed #35598 -- Added SearchInput widget. 2024-07-31 13:11:45 +02:00
Ben Cail
9cf9c796be Fixed #28646 -- Prevented duplicate index when unique is set to True on PostgreSQL. 2024-07-30 17:27:10 +02:00
Tim Graham
b6ad8b687a Added missing skips in constraint tests. 2024-07-26 18:59:12 +02:00
nessita
1b277b45cc
Added dedicated test for invalid inputs in floatformat template filter tests.
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-07-25 16:15:53 -03:00
Lorenzo Peña
0e94f292cd Fixed #35627 -- Raised a LookupError rather than an unhandled ValueError in get_supported_language_variant().
LocaleMiddleware didn't handle the ValueError raised by
get_supported_language_variant() when language codes were
over 500 characters.

Regression in 9e9792228a.
2024-07-25 09:38:46 +02:00
Devin Cox
cd0479ff76 Fixed #35331 -- Updated dropdown lists with entries added via the '+' sign from M2M field. 2024-07-25 08:52:24 +02:00
Simon Charette
f359990e49 Fixed #35625 -- Fixed a crash when adding a field with db_default and check constraint.
This is the exact same issue as refs #30408 but for creating a model with a
constraint containing % escapes instead of column addition. All of these issues
stem from a lack of SQL and parameters separation from the BaseConstraint DDL
generating methods preventing them from being mixed with other parts of the
schema alteration logic that do make use of parametrization on some backends
(e.g. Postgres, MySQL for DEFAULT).

Prior to the addition of Field.db_default and GeneratedField in 5.0
parametrization of DDL was never exercised on model creation so this is
effectively a bug with db_default as the GeneratedField case was addressed by
refs #35336.

Thanks Julien Chaumont for the report and Mariusz Felisiak for the review.
2024-07-25 07:48:53 +02:00
Sarah Boyce
8d6a20b656 Fixed #35604, Refs #35326 -- Made FileSystemStorage.exists() behaviour independent from allow_overwrite.
Partially reverts 0b33a3abc2.

Storage.exists(name) was documented to "return False if
the name is available for a new file." but return True if
the file exists. This is ambiguous in the overwrite file
case. It will now always return whether the file exists.

Thank you to Natalia Bidart and Josh Schneier for the
review.
2024-07-24 14:55:10 +02:00
Mariusz Felisiak
df35cf578f Updated asgiref dependency for 5.1 release series. 2024-07-24 08:21:07 +02:00
Mariusz Felisiak
9f5e2306e2
Refs #29049 -- Fixed isolation of BasicExpressionsTests._test_slicing_of_f_expressions() subtests.
Thanks Tim Graham for the report.
2024-07-23 14:29:14 -03:00
Mariusz Felisiak
b06cf62c88 Cleaned up temporary test directories in tests. 2024-07-22 08:51:01 +02:00
Bendeguz Csirmaz
bdd538488c Fixed #35614 -- Prevented SQLCompiler.as_subquery_condition() from mutating a query. 2024-07-22 08:34:29 +02:00
Simon Charette
9cb8baa0c4 Fixed #35559 -- Avoided unnecessary query on sliced union of empty queries.
While refs #34125 focused on the SQL correctness of slicing of union of
potentially empty queries it missed an optimization opportunity to avoid
performing a query at all when all queries are empty.

Thanks Lucidiot for the report.
2024-07-19 08:54:47 +02:00
Simon Charette
6b3f55446f Fixed #35603 -- Prevented F.__contains__() from hanging.
Regression in 94b6f101f7.
2024-07-18 08:39:10 +02:00
Hisham Mahmood
182f262b15 Fixed #35606, Refs #34045 -- Fixed rendering of ModelAdmin.action_checkbox for models with a __html__ method.
Thank you Claude Paroz for the report.

Regression in 85366fbca7.
2024-07-18 08:09:37 +02:00
Simon Charette
0e49a8c3bd Refs #34701 -- Moved UniqueConstraint(nulls_distinct) validation tests.
The original tests required the creation of a model that is no longer necessary
and were exercising Model.full_clean(validate_constraints) which has nothing
to do with the nulls_distinct feature.
2024-07-17 12:52:17 +02:00
Simon Charette
adc0b6aac3 Fixed #35594 -- Added unique nulls distinct validation for expressions.
Thanks Mark Gensler for the report.
2024-07-17 12:52:17 +02:00
Simon Charette
13922580cc Refs #30581 -- Made unattached UniqueConstraint(fields) validation testable.
The logic allowing UniqueConstraint(fields).validate to preserve backward
compatiblity with Model.unique_error_message failed to account for cases where
the constraint might not be attached to a model which is a common pattern
during testing.

This changes allows for arbitrary UniqueConstraint(fields) to be tested in
isolation without requiring actual models backing them up.

Co-authored-by: Mark G <mark.gensler@protonmail.com>
2024-07-17 12:52:17 +02:00
nessita
5dc17177c3
Refs #10941 -- Renamed test file test_query_string.py to test_querystring.py.
This follows previous renames made in 27043bde5b.
2024-07-16 22:14:52 -03:00
Sarah Boyce
27043bde5b
Refs #10941 -- Renamed query_string template tag to querystring. 2024-07-15 13:28:55 -03:00
Maryam Yusuf
65344f0e1e Refs #35464 -- Added test to cover layout of TabularInline fieldsets. 2024-07-15 12:43:42 +02:00
Sarah Boyce
86b548a59b Removed duplicate inline from tests.admin_inlines.admin.PhotographerAdmin. 2024-07-15 11:12:14 +02:00
Mariusz Felisiak
2d3bb414cf Refs #35560 -- Corrected required feature flags in GeneratedModelUniqueConstraint. 2024-07-15 10:20:09 +02:00
Adam Johnson
86e13843c2 Refs #25466 -- Removed unused DeprecationInstanceCheck.
Unused since ff419de263.
2024-07-11 09:40:07 +02:00
Tom Carrick
7264d7f750 Fixed syntax of CSS file used in tests. 2024-07-11 08:03:21 +02:00
Mike Edmunds
b9098538a9 Fixed #35033, Refs #28912 -- Fixed repeated headers in EmailMessage.
Fixed a regression which would cause multiple To, Cc, and
Reply-To headers in the result of EmailMessage.message() if
values were supplied for both to/cc/reply_to and the
corresponding extra_headers fields.

Updated related tests to check the generated message() has
exactly one of each expected header using get_all().

Regression in b03d500295.
2024-07-11 08:00:46 +02:00
Sarah Boyce
c6d1f98d26 Improved test coverage of urlize. 2024-07-10 09:32:02 +02:00
Daniel Patrick
d12184fedc Fixed #35424 -- Checked order_with_respect_to is available when migrating _order fields.
Migrations would crash following the removal of an order_with_respect_to
field from a model and the addition of an _order field.
2024-07-10 08:40:50 +02:00
Sarah Boyce
9e9792228a Fixed CVE-2024-39614 -- Mitigated potential DoS in get_supported_language_variant().
Language codes are now parsed with a maximum length limit of 500 chars.

Thanks to MProgrammer for the report.
2024-07-09 09:21:19 -03:00
Natalia
fe4a0bbe20 Fixed CVE-2024-39330 -- Added extra file name validation in Storage's save method.
Thanks to Josh Schneier for the report, and to Carlton Gibson and Sarah
Boyce for the reviews.
2024-07-09 09:21:19 -03:00
Michael Manfre
5d86458579 Fixed CVE-2024-39329 -- Standarized timing of verify_password() when checking unusuable passwords.
Refs #20760.

Thanks Michael Manfre for the fix and to Adam Johnson for the review.
2024-07-09 09:21:19 -03:00
Adam Johnson
d666457453 Fixed CVE-2024-38875 -- Mitigated potential DoS in urlize and urlizetrunc template filters.
Thank you to Elias Myllymäki for the report.

Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-07-09 09:21:19 -03:00
jason_bruce
af84bcc8d1 Fixed #35580 -- Allowed related fields referencing auto-created through models. 2024-07-09 13:50:12 +02:00
wookkl
759abc4daf Fixed #35413 -- Made unsupported lookup error message more specific. 2024-07-09 09:15:38 +02:00
Mark Gensler
1005c2abd1 Fixed #35560 -- Made Model.full_clean() ignore GeneratedFields for constraints.
Accessing generated field values on unsaved models caused a crash when
validating CheckConstraints and UniqueConstraints with expressions.
2024-07-04 11:45:15 +02:00
Jake Howard
53e674d574 Fixed #35520 -- Avoided opening transaction for read-only ModelAdmin requests. 2024-07-04 11:38:58 +02:00
Jacob Walls
31837dbcb3 Fixed #35569 -- Improved wording of invalid ForeignKey error message. 2024-07-04 11:35:03 +02:00
Simon Charette
6d220963fa Fixed #28900 -- Propagated all selected fields to combinator queries.
Previously, only the selected column aliases would be propagated and
annotations were ignored.
2024-07-03 16:36:25 +02:00
Simon Charette
65ad4ade74 Refs #28900 -- Made SELECT respect the order specified by values(*selected).
Previously the order was always extra_fields + model_fields + annotations with
respective local ordering inferred from the insertion order of *selected.

This commits introduces a new `Query.selected` propery that keeps tracks of the
global select order as specified by on values assignment. This is crucial
feature to allow the combination of queries mixing annotations and table
references.

It also allows the removal of the re-ordering shenanigans perform by
ValuesListIterable in order to re-map the tuples returned from the database
backend to the order specified by values_list() as they'll be in the right
order at query compilation time.

Refs #28553 as the initially reported issue that was only partially fixed
for annotations by d6b6e5d0fd.

Thanks Mariusz Felisiak and Sarah Boyce for review.
2024-07-03 16:36:25 +02:00
Mariusz Felisiak
8719a6181e
Refs #22712 -- Corrected deprecation of "all" argument in django.contrib.staticfiles.finders.find().
Features deprecated in Django 5.2 should be removed in Django 6.1.
2024-06-28 08:39:55 -03:00
Andreu Vallbona
0fdcf1029c Fixed #22712 -- Avoided name shadowing of "all" in django.contrib.staticfiles.finders.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-06-27 23:37:12 -03:00
Salvo Polizzi
dfac15d570 Fixed #35517, Refs #35515 -- Improved test coverage of shell command. 2024-06-27 16:42:55 +02:00
nessita
e56a32b89b
Fixed 35561 -- Made *args and **kwargs parsing more strict in Model.save()/asave(). 2024-06-26 12:13:17 -03:00
Sarah Boyce
e510bb1ab1
Fixed #35558 -- Increased inline H3 headers color prominence in admin change page. 2024-06-25 14:03:21 -03:00
Adam Johnson
28522c3c8d
Fixed #35554, Refs #35060 -- Corrected deprecated *args parsing in Model.save()/asave().
The transitional logic added to deprecate the usage of *args for
Model.save()/asave() introduced two issues that this branch fixes:
 * Passing extra positional arguments no longer raised TypeError.
 * Passing a positional but empty update_fields would save all fields.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-06-25 13:12:10 -03:00
Sarah Boyce
f1705c8780 Fixed #35545, Refs #32833 -- Fixed ContentTypeManager.get_for_models() crash in CreateModel migrations.
Thank you to Csirmaz Bendegúz for the report and Simon Charettes for the review.
2024-06-24 10:20:11 +02:00
Tim Graham
7ba2a0db20
Fixed Number.__str__() crash when float/decimal_value is None in expressions tests models. 2024-06-21 16:51:41 -03:00
Ronny Vedrilla
5fef6d2445 Fixed #35528 -- Added EmailMultiAlternatives.body_contains() helper method. 2024-06-21 12:00:56 +02:00
Mariusz Felisiak
20c2d625d3 Refs #35074 -- Avoided failed attempts to remove spatial indexes on nullable fields on MySQL.
MySQL doesn't support spatial indexes on NULL columns, so there is no
point in removing them.
2024-06-20 11:44:44 +02:00
Jake Howard
aba0e541ca Fixed #35537 -- Changed EmailMessage.attachments and EmailMultiAlternatives.alternatives to use namedtuples.
This makes it more descriptive to pull out the named fields.
2024-06-20 09:43:40 +02:00
Baptiste Mispelon
62300b81cf Fixed #12978 -- Added support for RSS feed stylesheets. 2024-06-18 17:25:43 +02:00
stefan.ivic
ce1ad98565 Fixed #35505 -- Added extrabody block to admin/base.html. 2024-06-18 16:49:53 +02:00
Mariusz Felisiak
a0c44d4e23 Simplified OperationTestCase.alter_gis_model() test hook a bit.
This avoids passing "blank=False" and "srid=4326" to field classes,
which are the default values, and removes special treatment for the
"blank" parameter.
2024-06-18 12:03:57 +02:00
Alexander Lötvall
38ad710aba Fixed #35483 -- Added NUL (0x00) character validation to ModelChoiceFields.
Applied the ProhibitNullCharactersValidator to ModelChoiceField and ModelMultipleChoiceField.

Co-authored-by: Viktor Paripás <viktor.paripas@gmail.com>
Co-authored-by: Vasyl Dizhak <vasyl@dizhak.com>
Co-authored-by: Arthur Vasconcelos <vasconcelos.arthur@gmail.com>
2024-06-17 12:19:26 +02:00
Mariusz Felisiak
fa78481467 Refs #34881 -- Fixed OperationTests.test_rename_m2m_field_with_2_references() test on Oracle. 2024-06-14 19:52:09 +02:00
Mariusz Felisiak
4ee68bb4f5 Fixed mail.tests.MailTests.test_backend_arg() test on Python 3.13+.
There is no point in asserting Python error messages.
2024-06-14 13:20:54 +02:00
Anže Pečar
e99187e5c9 Fixed #34881 -- Fixed a crash when renaming a model with multiple ManyToManyField.through references on SQLite.
Thank you to dennisvang for the report and Jase Hackman for the test.

Co-authored-by: Jase Hackman <jase.hackman@zapier.com>
2024-06-13 17:49:22 +02:00
Madalin Popa
d28626ecf8 Fixed #35488 -- Fixed BaseModelFormSet.validate_unique() crash due to unhashable type. 2024-06-13 16:21:53 +02:00
George Y. Kussumoto
2a32b23382 Fixed #35417 -- Updated BaseContext.new() with values to create a context that can be flattened. 2024-06-13 14:22:40 +02:00
Devin Cox
719a42b589 Fixed #34789 -- Prevented updateRelatedSelectsOptions from
adding entries to filter_horizontal chosen box.

Co-authored-by: yokeshwaran1 <yokesh440@yahoo.com>
2024-06-12 13:09:04 +02:00
Fabian Braun
339977d444 Fixed #35477 -- Corrected 'required' errors in auth password set/change forms.
The auth forms using SetPasswordMixin were incorrectly including the
'This field is required.' error when additional validations (e.g.,
overriding `clean_password1`) were performed and failed.
This fix ensures accurate error reporting for password fields.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-05-30 16:31:01 -03:00
Jake Howard
ff308a0604
Fixed 35467 -- Replaced urlparse with urlsplit where appropriate.
This work should not generate any change of functionality, and
`urlsplit` is approximately 6x faster.

Most use cases of `urlparse` didn't touch the path, so they can be
converted to `urlsplit` without any issue. Most of those which do use
`.path`, simply parse the URL, mutate the querystring, then put them
back together, which is also fine (so long as urlunsplit is used).
2024-05-29 10:48:27 -03:00
Carlton Gibson
f4a08b6ddf
Refs #35059 -- Used asyncio.Event in ASGITest.test_asyncio_cancel_error to enforce specific interleaving.
Sleep call leads to a hard to trace error in CI. Using an Event is
more deterministic, and should be less prone to environment
variations.

Bug in 11393ab131.
2024-05-28 14:36:34 -03:00
Jacob Walls
99f23eaabd Fixed #35469 -- Removed deferred SQL to create index removed by AlterField operation. 2024-05-28 12:44:07 +02:00
Simon Törnqvist
d3a7ed5bcc Fixed #35443 -- Changed ordinal to return negative numbers unchanged.
Previously, `-1` was converted to `"-1th"`. This has been updated to
return negative numbers "as is", so that for example `-1` is
converted to `"-1"`. This is now explicit in the docs.

Co-authored-by: Martin Jonson <artin.onson@gmail.com>
2024-05-27 10:54:25 +02:00
Mariusz Felisiak
b049bec7cf Fixed #35479 -- Dropped support for PostgreSQL 13 and PostGIS 3.0. 2024-05-27 09:49:25 +02:00
Tim Graham
bcbc4b9b8a Fixed typo in migrations test name. 2024-05-23 17:19:48 +02:00
Sarah Boyce
7e39ae5c8c Fixed #35472 -- Used temporary directory in test_imagefield.NoReadTests. 2024-05-22 16:37:23 -03:00
Natalia
04a208d7f1 Increased the default PBKDF2 iterations for Django 5.2. 2024-05-22 15:44:07 -03:00
Natalia
3a748cd0f5 Advanced deprecation warnings for Django 5.2. 2024-05-22 15:44:07 -03:00
Willem Van Onsem
2995aeab56 Fixed #35393 -- Added excluded pk as a hidden field to the inline admin. 2024-05-22 10:31:24 +02:00
Hisham Mahmood
c7fc9f20b4 Fixed #31405 -- Added LoginRequiredMiddleware.
Co-authored-by: Adam Johnson <me@adamj.eu>
Co-authored-by: Mehmet İnce <mehmet@mehmetince.net>
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-05-22 08:51:17 +02:00
Marijke Luttekes
e4a693f50a Fixed #35189 -- Improved admin collapsible fieldsets by using <details> elements.
This work improves the accessibility of the add and change pages in the
admin site by adding <details> and <summary> elements to the collapsible
fieldsets. This has the nice side effect of no longer requiring custom
JavaScript helpers to implement the fieldsets' show/hide capabilities.

Thanks to James Scholes for the accessibility advice, and to Sarah Boyce
and Tom Carrick for reviews.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-05-22 00:13:55 -03:00
Marijke Luttekes
01ed59f753 Refs #35189 -- Improved admin fieldset's accessibility by setting aria-labelledby.
Before this change, HTML <fieldset> elements in the admin site did not
have an associated label to describe them. This commit defines a unique
HTML id for the heading labeling a fieldset, and sets its
aria-labelledby property to link the heading with the fieldset.
2024-05-22 00:13:55 -03:00
John Parton
9c5fe93349 Fixed #35139 -- Prevented file read after ImageField is saved to storage. 2024-05-22 00:25:56 +02:00
Berker Peksag
4971a9afe5 Fixed #18119 -- Added a DomainNameValidator validator.
Thanks Claude Paroz for the review.

Co-authored-by: Nina Menezes <77671865+nmenezes0@users.noreply.github.com>
2024-05-21 23:11:12 +02:00
Adam Johnson
b9838c65ec Fixed #35405 -- Converted get_cache_name into a cached property in FieldCacheMixin.
FieldCacheMixin is used by related fields to track their cached values.
This work migrates get_cache_name() to be a cached property to optimize
performance by reducing unnecessary function calls when working with
related fields, given that its value remains constant.

Co-authored-by: Simon Charette <charette.s@gmail.com>
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-05-21 16:19:29 -03:00
Ryan Hiebert
c201014e85 Removed hardcoded docs version in csrf template. 2024-05-21 11:03:39 +02:00
Ben Cail
0b33a3abc2 Fixed #35326 -- Added allow_overwrite parameter to FileSystemStorage. 2024-05-21 07:28:12 +02:00
SaJH
8f205acea9 Fixed #35428 -- Increased parallelism of the ScryptPasswordHasher. 2024-05-17 17:13:58 +02:00
Mariusz Felisiak
604e32ee93 Fixed typos in test docstrings. 2024-05-16 07:57:58 +02:00
Jonny Park
c0b0ce85ed Fixed #35384 -- Raised FieldError when saving a file without a name to FileField. 2024-05-15 12:02:45 +02:00
Joachim Jablon
b691accea1 Fixed #29942 -- Restored source file linking in docs by using the Sphinx linkcode ext.
Co-authored-by: David Smith <smithdc@gmail.com>
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-05-14 22:08:29 -03:00
Mariusz Felisiak
f030236a86 Fixed #35275 -- Fixed Meta.constraints validation crash on UniqueConstraint with OpClass().
This also introduces Expression.constraint_validation_compatible that
allows specifying that expression should be ignored during a constraint
validation.
2024-05-14 10:34:30 +02:00
Adam Johnson
d2c5a30e5a Fixed #35408 -- Optimized post-migrate permission creation.
co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2024-05-13 08:34:57 +02:00
nessita
34f329ecac
Added tests for Storage's generate_filename method. 2024-05-10 08:51:47 -03:00
SaJH
4a76ac0e9d Fixed #35429 -- Added argparse choices to --database options. 2024-05-10 11:14:07 +02:00
SaJH
f92ac845a9 Fixed #35436 -- Fixed displaying Unicode chars in forms.HStoreField. 2024-05-10 09:42:07 +02:00
Adam Johnson
7abe5112f4 Fixed #35407 -- Cached model's Options.swapped. 2024-05-07 14:25:51 +02:00
Jacob Walls
ceea86baa3 Fixed #35425 -- Avoided INSERT with force_update and explicit pk.
Affected models where the primary key field is defined with a
default or db_default, such as UUIDField.
2024-05-07 12:15:27 +02:00
sobolevn
9a27c76021 Fixed #35426 -- Updated querysets to be a required argument of GenericPrefetch. 2024-05-04 11:30:36 +02:00
Mariusz Felisiak
91a4b9a8ec Fixed #35422 -- Fixed migrations crash when altering GeneratedField referencing rename field.
Thanks Sarah Boyce for the report and Simon Charette for the
implementation idea.
2024-05-03 09:28:24 +02:00
DevilsAutumn
9aeb38c296 Fixed #35359 -- Fixed migration operations ordering when adding fields referenced by GeneratedField.expression.
Thank you to Simon Charette for the review.
2024-05-02 21:43:13 -03:00
David Sanders
97d48cd3c6 Refs #34007, Refs #35359 -- Added Q.referenced_based_fields property.
Thank you to Mariusz Felisiak and Natalia Bidart for the reviews.
2024-05-02 19:05:13 +02:00
Sarah Boyce
39828fa778 Added a high contrast mode to screenshot cases.
Thank you to Sarah Abderemane and Nick Pope for the reviews.
2024-05-02 13:18:58 +02:00
David Smith
c187f5f924 Refs #32819 -- Avoided adding 'aria-describedby' to hidden inputs.
Hidden elements are not visible for both accessibility tools and browsers presentation layer. This change therefore only reduces the size of the generated HTML.
2024-04-30 11:11:02 +02:00
Mariusz Felisiak
85c154da2f Fixed #35412 -- Dropped support for SQLite < 3.31. 2024-04-29 11:07:54 +02:00
Chris Muthig
c8df2f9941 Fixed #35339 -- Fixed PostgreSQL aggregate's filter and order_by params order.
Updated OrderableAggMixin.as_sql() to separate the order_by parameters
from the filter parameters. Previously, the parameters and SQL were
calculated by the Aggregate parent class, resulting in a mixture of
order_by and filter parameters.

Thanks Simon Charette for the review.
2024-04-25 17:40:03 -03:00
Chris Muthig
42b567ab4c Refs #35339 -- Updated Aggregate class to return consistent source expressions.
Refactored the filter and order_by expressions in the Aggregate class to
return a list of Expression (or None) values, ensuring that the list
item is always available and represents the filter expression.
For the PostgreSQL OrderableAggMixin, the returned list will always
include the filter and the order_by value as the last two elements.

Lastly, emtpy Q objects passed directly into aggregate objects using
Aggregate.filter in admin facets are filtered out when resolving the
expression to avoid errors in get_refs().

Thanks Simon Charette for the review.
2024-04-25 17:40:03 -03:00
Tim Richardson
e64d42e753 Fixed #35395 -- slice filter crashes on an empty dict with Python 3.12.
Keep consistent behaviour of slice() filter between python 3.12 and prior
versions in the case of a dict passed to the filter (catch the new to python
3.12 KeyError exception).
2024-04-24 10:53:38 +02:00
Simon Charette
83f5478225 Fixed #35356 -- Deferred self-referential foreign key fields adequately.
While refs #34612 surfaced issues with reverse one-to-one fields
deferrals, it missed that switching to storing remote fields would break
self-referential relationships.

This change switches to storing related objects in the select mask
instead of remote fields to prevent collisions when dealing with
self-referential relationships that might have a different directional
mask.

Despite fixing #21204 introduced a crash under some self-referential
deferral conditions, it was simply not working even before that as it
aggregated the sets of deferred fields by model.

Thanks Joshua van Besouw for the report and Mariusz Felisiak for the
review.
2024-04-23 13:17:17 -03:00
Marijke Luttekes
2be37b2533 Made SeleniumTests.test_inline_add_another_widgets less flaky by adding explicit wait. 2024-04-17 17:38:04 +02:00
Simon Charette
d048f0d311 Fixed #35373 -- Fixed a crash when indexing a generated field on SQLite.
Generated fields have to be excluded from the INSERT query against the remade
table including the index.

Thanks Moshe Dicker for the report, David Sanders and Mariusz Felisiak for the
review.
2024-04-16 17:27:38 +02:00
Adam Johnson
50a702f3fd Fixed #35364 -- Stopped AdminEmailHandler rendering email unnecessarily. 2024-04-12 10:37:28 +02:00
Adam Johnson
b0f2289426 Refs #35364 -- Tested AdminEmailHandler with empty ADMINS. 2024-04-12 10:37:28 +02:00
Simon Charette
73b62a2126 Refs #35194 -- Adjusted a generated field test to work on Postgres 15.6+.
Postgres >= 12.18, 13.14, 14.11, 15.6, 16.2 changed the way the immutability
of generated and default expressions is detected in postgres/postgres@743ddaf.

The adjusted test semantic is presereved by switching from __icontains to
__contains as both make use of a `%` literal which requires proper escaping.

Refs #35336.

Thanks bcail for the report.
2024-04-12 10:23:04 +02:00
Sarah Boyce
f973a70bfc
Made postgresql.tests.Tests.test_connect_pool less flaky by increasing timeout value. 2024-04-10 14:09:52 -03:00
Natalia
338ec052b4 Refs #35361 -- Added test for Email line length checks when dealing with surrogate pairs.
Refs #33173, #34118 and #34900.
2024-04-10 17:56:55 +02:00
Sarah Boyce
8b53560eea Fixed #35350 -- Fixed save() with pk set on models with GeneratedFields.
Thanks Matt Hegarty for the report and Simon Charette and Natalia Bidart for the reviews.

Regression in f333e35.
2024-04-10 15:43:50 +02:00
Carlton Gibson
bcd255cd5c Fixed #35354 -- Simplified ASGIRequest path handling.
Following the ASGI HTTP Connection Scope docs[0], the provided `path`
is already the correct value that Django requires.

In combination with `root_path`, from which `script_name` is derived,
the `path_info` variable is set. It's then redundant to
re-calculate `path` from `script_name` and `path_info`.

See also, a clarifying discussion on the ASGIref repo[1].

[0]: https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope
[1]: https://github.com/django/asgiref/issues/424
2024-04-05 11:35:38 +02:00
Carlton Gibson
4d2ef9bb82 Refs #35169 -- Added test for ASGIRequest root_path handling. 2024-04-05 11:30:33 +02:00
Sarah Boyce
89403dbedd Fixed SeleniumTests.test_related_object_update_with_camel_casing() assert.
A selenium web element was compared to a string rather than its innerHTML.
2024-04-03 09:29:01 +02:00
devin13cox
8665cf03d7
Fixed #35330 -- Fixed the update of related widgets when the referenced model is camel case named.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-04-02 22:00:25 -03:00
Simon Charette
888b9042b3
Fixed #35336 -- Addressed crash when adding a GeneratedField with % literals.
A longer term solution is likely to have a better separation of parametrized
DDL altogether to handle checks, constraints, defaults, and generated fields
but such a change would require a significant refactor that isn't suitable
for a backport.

Thanks Adrian Garcia for the report.
2024-04-02 17:33:31 -03:00
Johannes Westphal
5f18021640 Fixed #35344, Refs #34838 -- Corrected output_field of resolved columns for GeneratedFields in aliased tables.
Thanks Simon Charette for the review.
2024-04-01 18:54:38 +01:00
Fabian Braun
944745afe2 Fixed #34977 -- Improved accessibility in the UserChangeForm by replacing the reset password link with a button.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-03-27 16:40:41 -03:00
Giannis Terzopoulos
d658a3162f Fixed #35233 -- Moved template engine system checks to backend methods.
Thanks Adam Johnson for reviews.
2024-03-27 08:14:54 +01:00
Mariusz Felisiak
b98271a6e4
Fixed #35329 -- Fixed migrations crash when adding partial unique constraints with nulls_distinct.
Bug in 595a2abb58.

Thanks Lucas Lemke Saunitti for the report.
2024-03-26 22:58:47 +01:00
Mariusz Felisiak
a2dcc4ecbb
Increased test coverage for django.db.migrations.operations.special. 2024-03-25 08:31:32 +01:00
Ben Cail
07c8d979ae Fixed #35323 -- Prevented file_move_safe() from trying to overwrite existing file when allow_overwrite is False. 2024-03-24 16:05:36 +01:00
Mariusz Felisiak
1c11dba835
Added ModelState.from_model() test for abstract model with unnamed indexes. 2024-03-22 13:31:33 +01:00
sharonwoo
6a37e9bfae Fixed #35257 -- Corrected resolving output_field for IntegerField/DecimalField with NULL. 2024-03-21 10:13:54 +01:00
Mariusz Felisiak
6f7c0a4d66
Fixed ResourceWarning from unclosed SQLite connection in test_utils on Python 3.13+.
On SQLite, close() doesn't explicitly close in-memory connections.

Follow up to 921670c694 and
dd45d5223b.
2024-03-20 11:44:30 +01:00
Laurent Lyaudet
f2388a4b73 Fixed #35309 -- Made prefetch clear ordering for single-valued relationships. 2024-03-20 05:26:18 +01:00
Mariusz Felisiak
921670c694
Fixed ResourceWarning from unclosed SQLite connection on Python 3.13+.
On SQLite, close() doesn't explicitly close in-memory connections.

Follow up to dd45d5223b.
2024-03-19 10:03:12 +01:00
Claude Paroz
10b31eea33 Refs #31014 -- Added srid argument to FromWKB/FromWKT() GIS functions. 2024-03-18 09:45:33 +01:00
Adam Johnson
7646b9023d
Fixed #35301 -- Fixed Options._property_names for overriden properties.
Regression in faeb92ea13.
2024-03-17 09:43:04 +01:00
Adam Johnson
cbf1e87398 Fixed #35294 -- Fixed TEXT format of QuerySet.explain() for long plans.
co-authored-by: Gordon <gordon.wrigley@gmail.com>
co-authored-by: Simon Charette <charette.s@gmail.com>
2024-03-15 06:58:14 +01:00
Ben Cail
593067a8ee Fixed #28541 -- Fixed migrations crash when changing primary key on SQLite. 2024-03-14 20:56:43 +01:00
Johannes Maron
3d7235c67b Refs #34488 -- Made ClearableFileInput preserve "Clear" checked attribute when form is invalid. 2024-03-14 14:03:14 +01:00
Johannes Maron
e69019555d Fixed #35273 -- Fixed rendering AdminFileWidget's attributes.
Regression in 8a6c0203c4.
2024-03-14 14:03:09 +01:00
Jon Janzen
f5c340684b Fixed #34901 -- Added async-compatible interface to session engines.
Thanks Andrew-Chen-Wang for the initial implementation which was posted
to the Django forum thread about asyncifying contrib modules.
2024-03-13 17:55:15 +01:00
Mariusz Felisiak
33c06ca0da
Refs #32673, Refs #35295 -- Avoided wrapping rhs direct values in lookups. 2024-03-13 17:46:37 +01:00
Claude Paroz
894fa55da1
Applied BoundingCircle test to only one country.
Looks like testing the second Country is much more computing-intensive
and brings nothing to the test.
2024-03-10 20:59:36 +01:00
Giannis Terzopoulos
73df8b54a2 Fixed #35044 -- Avoided clearing reverse relations and private fields when accessing deferred fields.
Regression in a7b5ad8b19 for reverse
relations and possibly in 123b1d3fcf for
private fields.
2024-03-08 11:09:54 +01:00
Giannis Terzopoulos
0c690c6001 Refs #35044 -- Added Model.refresh_from_db(fields=...) test for clearing reverse relations. 2024-03-08 10:27:19 +01:00
Ben Cail
1570ef02f3 Fixed #35223 -- Made Model.full_clean() ignore fields with db_default when validating empty values.
Thanks Brian Ibbotson for the report.

Regression in 7414704e88.
2024-03-08 05:55:25 +01:00
Dingning
549320946d Fixed #35030 -- Made django.contrib.auth decorators to work with async functions. 2024-03-07 09:59:33 +01:00
cuinix
20848bcf39 Fixed typos in docstrings and docs.
Signed-off-by: cuinix <915115094@qq.com>
2024-03-07 06:01:01 +01:00
Mariusz Felisiak
c4df2a7776
Refs #35030 -- Added more tests for @user_passes_test decorator. 2024-03-06 13:28:32 +01:00
Michail Chatzis
4426b1a72d Fixed #35021 -- Fixed capturing queries when using client-side parameters binding with psycopg 3+. 2024-03-06 11:24:58 +01:00
Adam Johnson
eff21d8e7a Fixed #35252 -- Optimized _route_to_regex().
co-authored-by: Nick Pope <nick@nickpope.me.uk>
2024-03-05 13:09:10 +01:00
Mariusz Felisiak
241adf678f
Used sys_platform in tests requirements.
We already use implementation_name and python_version markers
so it's more consistent. Moreover, marker values can be specified
via pip's command line options.
2024-03-05 13:08:23 +01:00
Adam Zapletal
3d4fe39bac Refs #21286 -- Removed invalid commented out models and tests from serializer tests.
FileField/ImageField cannot be primary keys, so serialization support
for this case will not be implemented.

XMLField was removed in d1290b5b43.
2024-03-04 11:38:18 +01:00
Mariusz Felisiak
838659ea21
Updated fuzzy translations in tests.i18n.patterns.
Follow up to 9fd1b6f3f8.
2024-03-04 11:24:21 +01:00
Shai Berger
f6ad8c7676 Refs CVE-2024-27351 -- Forwardported release notes and tests.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2024-03-04 08:22:00 +01:00