Commit Graph

18738 Commits

Author SHA1 Message Date
Mariusz Felisiak ce6230aa97
Fixed #34015 -- Allowed filtering by transforms on relation fields. 2022-09-22 00:17:04 +02:00
Alexander Kerkum f88fc72da4 Fixed #34016 -- Fixed QuerySet.values()/values_list() crash on ArrayAgg() and JSONBAgg().
Regression in e06dc4571e.
2022-09-17 19:38:20 +02:00
Kamil Turek ae509f8f08 Fixed #34014 -- Fixed DecimalValidator validating 0 in positive exponent scientific notation.
Thanks Shiplu Mokaddim for the report.
2022-09-17 10:02:55 +02:00
Allen Jonathan David 10178197d5 Fixed #33966 -- Added support for using KeyTextTransform from lookup. 2022-09-16 05:36:57 +02:00
Simon Charette 3ba7f2e906
Refs #28333 -- Explicitly ordered outer qualify query on window filtering.
While most backends will propagate derived table ordering as long as
the outer query doesn't perform additional processing the SQL specs
doesn't explicitly state the ordering must be maintained.
2022-09-15 19:27:32 +02:00
Jay Patel a69b0e9cfe
Fixed #33994 -- Corrected position of extrastyle and extrahead blocks in admin base template. 2022-09-15 14:33:41 +02:00
Youngkwang Yang cd11664066 Changed camel case variable to snake case in contrib.admin/auth. 2022-09-15 13:26:55 +02:00
Anvesh Mishra 6220c445c4 Fixed #29186 -- Fixed pickling HttpRequest and subclasses. 2022-09-14 13:04:34 +02:00
David Sanders e14d08cd89 Fixed #33996 -- Fixed CheckConstraint validation on NULL values.
Bug in 667105877e.

Thanks James Beith for the report.
2022-09-13 12:48:31 +02:00
Sergey Fursov b731e88415 Fixed #31335 -- Fixed removing composed composed Meta constraints/indexes on foreign keys on MySQL. 2022-09-13 10:38:57 +02:00
Jimmy Angelakos 07ebef566f Refs #34000 -- Optimized handling None values in numberformat.format(). 2022-09-12 13:02:50 +02:00
Jimmy Angelakos e911e0996f Fixed #34000 -- Fixed numberformat.format() crash on empty strings. 2022-09-12 12:54:12 +02:00
Sergey Fursov ec13e801b8 Refs #31335 -- Added SchemaEditor._create_missing_fk_index() on MySQL. 2022-09-12 08:52:18 +02:00
DevilsAutumn f3cd252cfc Fixed #33995 -- Fixed FormSet.empty_form crash when empty_permitted is passed to form_kwargs. 2022-09-09 13:51:47 +02:00
DevilsAutumn 32797e7fbf Fixed #33975 -- Fixed __in lookup when rhs is a queryset with annotate() and alias().
This fixes clearing selected fields.
2022-09-09 08:37:46 +02:00
Tom Carrick 0c3981eb50
Used CSS flex and <nav> for ModelAdmin.date_hierarchy. 2022-09-08 13:52:36 +02:00
Simon Charette 32536b1324 Fixed #33992 -- Fixed queryset crash when aggregating over a group containing Exists.
A more in-depth solution is likely to make sure that we always GROUP BY
selected annotations or revisit how we use Query.exists() in the Exists
expression but that requires extra work that isn't suitable for a
backport.

Regression in e5a92d400a.

Thanks Fernando Flores Villaça for the report.
2022-09-08 05:50:02 +02:00
Shai Berger 42cd8c390d Fixed #33986 -- Hardened binary lookup in template commands.
Made template commands look up formatters before writing files.
This makes sure files included in the template are not identified
as executable formatter commands, even in case the template is
rendered into the system path (as might easily happen on Windows,
where the current directory is on the system path by default).

While at it, Warned about trusting custom templates for
startapp/startproject.

Thanks Trung Pham of Viettel Cyber Security for reporting the issue,
Django Security Team for discussions, and Adam Johnson and
Carlton Gibson for reviews.
2022-09-07 11:08:43 +02:00
James Beith 19e838daa8 Fixed #33982 -- Fixed migrations crash when adding model with ExclusionConstraint.
Regression in 0e656c02fe.
2022-09-07 08:40:56 +02:00
DevilsAutumn 3a084831e2 Refs #33616 -- Updated BaseDatabaseWrapper.run_on_commit comment. 2022-09-06 20:50:57 +02:00
SirAbhi13 4a1150b41d Fixed #33616 -- Allowed registering callbacks that can fail in transaction.on_commit().
Thanks David Wobrock and Mariusz Felisiak for reviews.
2022-09-06 12:21:36 +02:00
Gav O'Connor be63c78760 Fixed #24179 -- Added filtering to selected side of vertical/horizontal filters. 2022-09-06 10:46:58 +02:00
Mariusz Felisiak 69fa2e8eb2
Refs #26780 -- Made prefetch_related() don't use window expressions fo sliced queries if not supported. 2022-09-06 05:54:35 +02:00
Mark Evans 19e0587ee5 Fixed #33937 -- Optimized serialization of related m2m fields without natural keys. 2022-09-05 20:23:32 +02:00
Allen Jonathan David cd1afd553f Fixed #29799 -- Allowed registering lookups per field instances.
Thanks Simon Charette and Mariusz Felisiak for reviews and mentoring
this Google Summer of Code 2022 project.
2022-09-02 10:02:24 +02:00
Shai Berger fdf0f62521 Fixed ReadOnlyPasswordHashWidget's template for RTL languages. 2022-09-01 21:20:15 +02:00
Mariusz Felisiak 974942a750
Fixed #33955, Fixed #33971 -- Reverted "Fixed #32565 -- Moved internal URLResolver view-strings mapping to admindocs."
This reverts commit 7f3cfaa12b.

Thanks Tom Carrick and Greg Kaleka for reports.
2022-09-01 21:09:16 +02:00
Swara 12617fbd85 Corrected the direction of arrows in admin selector boxes for RTL languages. 2022-08-31 08:03:39 +02:00
Swara 08303f4f06 Added Central Kurdish (Sorani) language. 2022-08-30 11:56:11 +02:00
Alex Morega de6c9c7054 Refs #30947 -- Changed tuples to lists where appropriate. 2022-08-30 09:57:17 +02:00
Simon Charette b3db6c8dcb Fixed #21204 -- Tracked field deferrals by field instead of models.
This ensures field deferral works properly when a model is involved
more than once in the same query with a distinct deferral mask.
2022-08-30 08:43:53 +02:00
Simon Charette 60613ef516 Merged nested if statements in select_related_descend(). 2022-08-30 06:59:55 +02:00
Mariusz Felisiak 4483a9b12f
Fixed #33960 -- Fixed migrations crash on SQLite < 3.26.
Regression in 0b95a96ee1.

Thanks Aristotelis Mikropoulos for the report.
2022-08-29 09:55:45 +02:00
Mohamed Karam b92ffebb0c Fixed #33954 -- Prevented models.DecimalField from accepting NaN, Inf, and -Inf values. 2022-08-27 15:51:08 +02:00
David Wobrock 806e9e2d0d Fixed #33952 -- Reallowed creating reverse foreign key managers on unsaved instances.
Thanks Claude Paroz for the report.

Regression in 7ba6ebe914.
2022-08-27 15:03:48 +02:00
Simon Charette 0701bb8e1f Fixed #33928 -- Avoided unnecessary queries when cascade updating.
Models that use SET, SET_NULL, and SET_DEFAULT as on_delete handler
don't have to fetch objects for the sole purpose of passing them back to
a follow up UPDATE query filtered by the retrieved objects primary key.

This was achieved by flagging SET handlers as _lazy_ and having the
collector logic defer object collections until the last minute. This
should ensure that the rare cases where custom on_delete handlers are
defined remain uncalled when when dealing with an empty collection of
instances.

This reduces the number queries required to apply SET handlers from
2 to 1 where the remaining UPDATE use the same predicate as the non
removed SELECT query.

In a lot of ways this is similar to the fast-delete optimization that
was added in #18676 but for updates this time. The conditions only
happen to be simpler in this case because SET handlers are always
terminal. They never cascade to more deletes that can be combined.

Thanks Renan GEHAN for the report.
2022-08-27 14:25:55 +02:00
Simon Charette a9be1dc551 Refs #33928 -- Removed unnecessary attribute assignment on on-delete updates.
Model instances retrieved for bulk field update purposes are not exposed
to the outside world and thus are not required to be kept update to
date.
2022-08-27 14:25:50 +02:00
Iuri de Silvio 166a3b3263 Fixed #33953 -- Reverted "Fixed #33201 -- Made RenameModel operation a noop for models with db_table."
Regression in afeafd6036.
This reverts afeafd6036.

Thanks Timothy Thomas for the report.
2022-08-26 06:14:44 +02:00
Simon Charette 71902e0d9f Fixed #33938 -- Fixed migration crash for m2m with a through model in another app.
Regression in aa4acc164d.

Thanks bryangeplant for the report.
2022-08-25 10:03:57 +02:00
Jan Pieter Waagmeester 2480554dc4
Fixed typo in django/db/models/fields/files.py comment. 2022-08-25 09:41:33 +02:00
Neeraj Kumar 9942f3fb49 Fixed #33830 -- Fixed VariableDoesNotExist when rendering ClearableFileInput. 2022-08-25 07:52:36 +02:00
Willem Van Onsem 16fffc829c Fixed #33916 -- Added support for serialization of enum.Flag in migrations. 2022-08-25 06:43:48 +02:00
David Wobrock 897f38fabe Fixed #33927 -- Fixed crash when displaying ArrayField with choices in admin. 2022-08-23 15:51:42 +02:00
Claude Paroz 903ac2f364 Fixed #33949 -- Fixed fixture dirs duplicates with Path instances. 2022-08-23 13:24:18 +02:00
Mariusz Felisiak e9fd2b5724
Refs #26511 -- Fixed json.KeyTextTransform() on MySQL/MariaDB. 2022-08-18 21:02:29 +02:00
Tom Carrick bd36023100 Used CSS flex for admin's submit row. 2022-08-18 12:29:40 +02:00
Jacob Rief aed60aee38 Fixed #33930 -- Eased customization of delete_confirmation.html template in the admin. 2022-08-18 10:51:12 +02:00
Benoît Vinot e3cb8bcb7d Fixed #33932 -- Fixed altering AutoFields to OneToOneField on PostgreSQL.
Regression in 2eea361eff.
2022-08-17 17:06:00 +02:00
Carlton Gibson e1056ed5a2 Refs #33491 -- Split CSS selected-row highlight selectors.
Combined selectors break the whole rule where :has() is not supported,
for example on Firefox.

Thanks to Marcelo Galigniana for the report.
2022-08-17 14:18:38 +02:00
Marcelo Galigniana 0aa2f16e63 Fixed #33491 -- Fixed change-list selected row-highlight on cancelled delete.
Selected rows where not highlighted when returning to the change-list
after clicking "No, take me back" on the deletion confirmation page.

This commit uses the CSS :has() pseudo-class to apply the highlight
without requiring the .selected class, which is added by JavaScript
on the click event.

Once all supported browsers have :has() available, the .selected
selector and the JavaScript to add the class can be removed.

Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
2022-08-17 11:49:34 +02:00
Tom Carrick d46cc15c51 Fixed #33878 -- Switched to system fonts in CSS. 2022-08-17 10:19:00 +02:00
Tom Carrick 43ddce0aeb Fixed CSS variable indentation.
Matches 4-space indentation used elsewhere in project CSS files.
2022-08-17 10:19:00 +02:00
Simon Charette 242499f2dc Fixed #26780 -- Added prefetch_related() support for sliced queries.
This was made possible by window function filtering support added in
f387d024fc.
2022-08-15 10:25:20 +02:00
Simon Charette f387d024fc Refs #28333 -- Added partial support for filtering against window functions.
Adds support for joint predicates against window annotations through
subquery wrapping while maintaining errors for disjointed filter
attempts.

The "qualify" wording was used to refer to predicates against window
annotations as it's the name of a specialized Snowflake extension to
SQL that is to window functions what HAVING is to aggregates.

While not complete the implementation should cover most of the common
use cases for filtering against window functions without requiring
the complex subquery pushdown and predicate re-aliasing machinery to
deal with disjointed predicates against columns, aggregates, and window
functions.

A complete disjointed filtering implementation should likely be
deferred until proper QUALIFY support lands or the ORM gains a proper
subquery pushdown interface.
2022-08-15 08:26:26 +02:00
Haolun Chai f3f9d03edf Fixed #33901 -- Skipped varchar_pattern_ops/text_pattern_ops index creation when db_collation is set. 2022-08-15 06:28:35 +02:00
Mariusz Felisiak 5c803bc070
Fixed #33919 -- Fixed adding AutoFields on PostgreSQL.
Thanks Jack Calvin Brown for the report.

Regression in 2eea361eff.
2022-08-12 17:30:23 +02:00
Claude Paroz 4fcba800b8 Fixed #33924 -- Deprecated BaseGeometryWidget.map_height/map_width attributes. 2022-08-12 13:26:35 +02:00
Simon Charette 8c3046daad Refs #28333 -- Moved SQLCompiler's forced column aliasing logic to get_select().
This extends query composability possibilities when dealing with
subqueries which is necessary to implement window function filtering.
2022-08-11 12:39:54 +02:00
Carlton Gibson e34dfad0a3 Refs #30213 -- Removed post-startup check for Watchman availability.
This is checked at startup in get_reloader(). The runtime check ties
the implementation to Watchman excessively.
2022-08-11 11:02:03 +02:00
Simon Charette 35911078fa Replaced Expression.replace_references() with .replace_expressions().
The latter allows for more generic use cases beyond the currently
limited ones constraints validation has.

Refs #28333, #30581.
2022-08-11 09:53:10 +02:00
Mariusz Felisiak 8533a6af8d Optimized ExclusionConstraint.validate() a bit.
References to excluded fields are omitted in the replacement_map, so
there is no need to replace references before checking for exclusions.
2022-08-11 09:53:10 +02:00
Mariusz Felisiak fc0942ada4 Used F.replace_references().
Follow up to 63884829ac.
2022-08-11 09:53:10 +02:00
Rust Saiargaliev 8403da3696
Fixed #28975 -- Made PostGIS backend skip extension creation if installed. 2022-08-10 13:42:53 +02:00
Mariusz Felisiak 721706f4c4
Refs #33895 -- Fixed Case() crash with filters that match everything in When() on Oracle.
Follow up to 036bb2b74a.
2022-08-10 12:28:39 +02:00
David Sanders e0ae1363ec Fixed #33905 -- Fixed CheckConstraint() validation on range fields.
Bug in 667105877e.
2022-08-09 20:13:21 +02:00
Mariusz Felisiak f3a06b06b5
Removed unused InlineAdminForm.ordering_field().
Unused since its introduction in a19ed8aea3.
2022-08-09 09:26:12 +02:00
David Wobrock 036bb2b74a Fixed #33895 -- Fixed Case() crash with filters that match everything in When().
Thanks shukryzablah for the report.
2022-08-09 07:55:31 +02:00
Mariusz Felisiak 63884829ac
Fixed #33902 -- Fixed Meta.constraints validation crash with F() expressions.
Thanks Adam Zahradník for the report.

Bug in 667105877e.
2022-08-09 06:08:48 +02:00
Kamil Turek e03cdf76e7 Fixed #31721 -- Allowed ModelForm meta to specify form fields. 2022-08-08 09:46:05 +02:00
Fiza Ashraf c0beff2123 Fixed #33899 -- Fixed migration crash when removing indexed field on SQLite 3.35.5+.
Regression in 702819227fd0cdd9b581cd99e11d1561d51cbeb.

Thanks cessor for the report.
2022-08-08 06:28:53 +02:00
Mariusz Felisiak fd93db97c7
Fixed #33898 -- Fixed Window() expression crash with ArrayAgg().
Thanks Kia for the report.

Regression in e06dc4571e.
2022-08-06 17:59:31 +02:00
Fab 0756c61f2a Fixed #33893 -- Reverted "Fixed #28889 -- Prevented double submission of admin forms."
Regression in fe7dbef586.
2022-08-05 16:38:52 +02:00
Mariusz Felisiak d4db417c8e
Fixed #33891 -- Fixed test command crash when running in parallel using spawn.
Thanks Kevin Renskers for the report.

Regression in 41c4cb253c.
2022-08-04 09:16:38 +02:00
Claude Paroz 0638b4e23d Fixed #33888 -- Fixed get_select2_language() crash with no language activated.
Regression in 3079133c73.
2022-08-03 19:51:25 +02:00
Aarni Koskela e7afb8a180 Fixed #33886 -- Reallowed using GeoIP2() when GEOS is not installed.
Regression in 31bef51d8e.
2022-08-03 16:55:23 +02:00
Mariusz Felisiak cb791a2540
Fixed #33872 -- Deprecated django.contrib.postgres.fields.CIText/CICharField/CIEmailField/CITextField. 2022-08-03 11:42:51 +02:00
Carlton Gibson bd062445cf Fixed CVE-2022-36359 -- Escaped filename in Content-Disposition header.
Thanks to Motoyasu Saburi for the report.
2022-08-03 08:46:31 +02:00
Mariusz Felisiak 919e65b21e Updated translations from Transifex.
This also fixes related i18n tests.

Forwardport of a3bab93324 from stable/4.1.x.

Co-authored-by: Claude Paroz <claude@2xlibre.net>
2022-08-03 08:04:34 +02:00
Sarah Abderemane bc7aa2a5e9 Fixed #33690 -- Added switch button for dark mode in the admin. 2022-08-02 17:14:24 +02:00
Mariusz Felisiak ab1955a05e
Fixed #33881 -- Added support for database collations to ArrayField(Char/TextFields). 2022-08-02 11:44:26 +02:00
Carlton Gibson 89e695a69b Fixed #33876, Refs #32229 -- Made management forms render with div.html template.
Thanks to Claude Paroz for the report.
2022-08-02 10:30:09 +02:00
Claude Paroz 44c24bf028 Refs #25706 -- Removed inline CSS in the openlayers widget template. 2022-08-01 20:29:49 +02:00
Claude Paroz 2aa6fb2121
Made MapWidget a JS class. 2022-08-01 09:33:08 +02:00
Mariusz Felisiak c18861804f Fixed warnings per flake8 5.0.0. 2022-07-31 08:16:19 +02:00
Claude Paroz 1e5bbbb2a8 Fixed #33442 -- Allowed GeoIP2 to use DB-IP Lite datasets. 2022-07-30 19:29:45 +02:00
Marcelo Galigniana 564437f767 Fixed #33726 -- Added skip-link to admin for keyboard navigation. 2022-07-28 11:52:48 +02:00
Mariusz Felisiak 88dba2e3fd
Fixed collation tests on MySQL 8.0.30+.
The utf8_ collations are renamed to utf8mb3_* on MySQL 8.0.30+.
2022-07-27 21:36:25 +02:00
Nick Pope 9dff316be4 Refs #32948, Refs #32946 -- Used Q.create() internally for dynamic Q() objects.
Node.create() which has a compatible signature with Node.__init__()
takes in a single `children` argument rather than relying in unpacking
*args in Q.__init__() which calls Node.__init__().

In addition, we were often needing to unpack iterables into *args and
can instead pass a list direct to Node.create().
2022-07-27 10:06:24 +02:00
Nick Pope 845667f2d1 Refs #32948 -- Simplified and optimized Q._combine() and __invert__().
- Removed use of Q.deconstruct() in Q._combine().
- Simplified and optimized Q.__invert__() by taking a shallow copy and
  swapping the negated attribute only.
- Simplified construction in Q._combine().
- Simplified conditions in Q._combine() as Q.conditional = True the
  first isinstance() check is unnecessary.
- Removed copy.copy() branch in Q._combine().

Co-authored-by: Keryn Knight <keryn@kerynknight.com>
2022-07-27 10:06:24 +02:00
Nick Pope 19b866c254 Refs #32948 -- Added Node.__copy__().
This allows the copy.copy() usage in the Q._combine() method to finish
sooner, instead of having to fallback to using the __reduce_ex__(4)
method.

Thia also avoids having to fall into copy.copy() at in Q._combine(),
when combining a Q() with another Q().

Co-authored-by: Keryn Knight <keryn@kerynknight.com>
2022-07-27 10:06:24 +02:00
Nick Pope ed9eca8457 Refs #32948 -- Simplified WhereNode and Node.__deepcopy__()/add().
We can use copy() in Node.add() instead of create() as we don't need the
children to be cloned via [:] subscript in __init__().
2022-07-27 10:06:24 +02:00
Nick Pope ddf0002bb7 Refs #32948 -- Renamed Node._new_instance() to Node.create().
Node._new_instance() was added in
6dd2b5468f to work around Q.__init__()
having an incompatible signature with Node.__init__().

It was intended as a hook that could be overridden if subclasses needed
to change the behaviour of instantiation of their specialised form of
Node. In practice this doesn't ever seem to have been used for this
purpose and there are very few calls to Node._new_instance() with other
code, e.g. Node.__deepcopy__() calling Node and overriding __class__ as
required.

Rename this to Node.create() to make it a more "official" piece of
private API that we can use to simplify a lot of other areas internally.

The docstring and nearby comment have been reworded to read more
clearly.
2022-07-27 10:06:24 +02:00
Nick Pope 4f8bc75bc3 Removed obsolete docstring from WhereNode.clone().
Node.subtree_parents was removed in
d3f00bd570. That commit also added
Q.clone() which was identical to WhereNode.clone(), but lacked the
docstring. Q.clone() was later removed in
b454e2cbc9.
2022-07-27 07:55:09 +02:00
Nick Pope 769d7cce4a Used AND, OR, XOR constants instead of hard-coded values. 2022-07-27 07:55:09 +02:00
Mariusz Felisiak 66f30dbf25 Refs #27236 -- Reverted "Refs #27236 -- Refactored out DeprecationForHistoricalMigrationMixin."
This reverts commit 57793b4765.
2022-07-26 11:41:19 +02:00
Mariusz Felisiak a1e9e9abc5 Refs #27236 -- Reverted "Refs #27236 -- Added generic mechanism to handle the deprecation of migration operations."
This reverts commit 41019e48bb.
2022-07-26 11:41:19 +02:00
Mariusz Felisiak c773d5794e Refs #27236 -- Reverted AlterIndexTogether deprecation.
This partly reverts a6385b382e.
2022-07-26 11:41:19 +02:00
Claude Paroz 2d23a07817 Fixed #33866 -- Added pathlib.Path support to GDALRaster constructor. 2022-07-25 20:48:33 +02:00
Nick Pope 36cd425943 Simplified various built-in templates.
- Using the {% plural %} tag.
- Using the |yesno filter.
- Using the |unordered_list filter.
- Unnesting {% if %} where not required.
- Not duplicating {% if %}.
2022-07-25 10:20:46 +02:00
Nick Pope 390832e04a Standardized formatting in technical 500 template.
- Prefer use of `k` and `v` instead of `var.0` and `var.1`.
- Fixed indentation of #files-info block to match adjacent blocks.
2022-07-25 10:19:47 +02:00