From a08f1693f37e9aae9eca395020cce0638cb5aa5f Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Wed, 26 Nov 2025 07:17:39 -0500 Subject: [PATCH 1/4] Closed temporary files in OverwritingStorageTests.test_save_overwrite_behavior_temp_file(). --- tests/file_storage/tests.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index 92962bd9a062..c9539c1cf985 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -671,9 +671,11 @@ def test_save_overwrite_behavior_temp_file(self): content_1 = b"content one" content_2 = b"second content" f_1 = TemporaryUploadedFile("tmp1", "text/plain", 11, "utf8") + self.addCleanup(f_1.close) f_1.write(content_1) f_1.seek(0) f_2 = TemporaryUploadedFile("tmp2", "text/plain", 14, "utf8") + self.addCleanup(f_2.close) f_2.write(content_2) f_2.seek(0) stored_name_1 = self.storage.save(name, f_1) From e48527f91d341c85a652499a5baaf725d36ae54f Mon Sep 17 00:00:00 2001 From: Natalia <124304+nessita@users.noreply.github.com> Date: Tue, 25 Nov 2025 22:18:50 -0300 Subject: [PATCH 2/4] Added timeout-minutes directive to all GitHub Actions workflows. GitHub Actions defaults to a 360-minute (6-hour) timeout. We've had jobs hang due to issues in the parallel test runner, causing them to run for the full 6 hours. This wastes resources and negatively impacts CI availability, so explicit timeouts have been added to prevent long-running hangs. --- .github/workflows/benchmark.yml | 1 + .github/workflows/check_commit_messages.yml | 1 + .github/workflows/docs.yml | 3 +++ .github/workflows/labels.yml | 1 + .github/workflows/linters.yml | 4 ++++ .github/workflows/new_contributor_pr.yml | 1 + .github/workflows/postgis.yml | 1 + .github/workflows/python_matrix.yml | 2 ++ .github/workflows/schedule_tests.yml | 6 ++++++ .github/workflows/schedules.yml | 1 + .github/workflows/screenshots.yml | 1 + .github/workflows/selenium.yml | 2 ++ .github/workflows/tests.yml | 2 ++ 13 files changed, 26 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index c803546c78e7..7ffb02259366 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -11,6 +11,7 @@ jobs: Run_benchmarks: if: contains(github.event.pull_request.labels.*.name, 'benchmark') runs-on: ubuntu-latest + timeout-minutes: 60 steps: - name: Checkout Benchmark Repo uses: actions/checkout@v5 diff --git a/.github/workflows/check_commit_messages.yml b/.github/workflows/check_commit_messages.yml index ece0bcac4ee1..fe67536eb547 100644 --- a/.github/workflows/check_commit_messages.yml +++ b/.github/workflows/check_commit_messages.yml @@ -15,6 +15,7 @@ jobs: check-commit-prefix: if: startsWith(github.event.pull_request.base.ref, 'stable/') runs-on: ubuntu-latest + timeout-minutes: 60 steps: - uses: actions/checkout@v5 with: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4100c9ea2133..bfa4f9cb52e3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,6 +23,7 @@ jobs: docs: runs-on: ubuntu-24.04 name: spelling + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -43,6 +44,7 @@ jobs: blacken-docs: runs-on: ubuntu-latest name: blacken-docs + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -66,6 +68,7 @@ jobs: lint-docs: runs-on: ubuntu-latest name: lint-docs + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 79ee8af59d42..807563322fa1 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -19,6 +19,7 @@ jobs: if: github.repository == 'django/django' name: "Flag if no Trac ticket is found in the title" runs-on: ubuntu-latest + timeout-minutes: 60 steps: - uses: actions/checkout@v5 with: diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 7b58bacacf40..0f916fa24f16 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -21,6 +21,7 @@ jobs: flake8: name: flake8 runs-on: ubuntu-latest + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -40,6 +41,7 @@ jobs: isort: runs-on: ubuntu-latest + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -59,6 +61,7 @@ jobs: black: runs-on: ubuntu-latest + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -69,6 +72,7 @@ jobs: zizmor: runs-on: ubuntu-latest + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 diff --git a/.github/workflows/new_contributor_pr.yml b/.github/workflows/new_contributor_pr.yml index 194adb3bb860..054ee0f1d578 100644 --- a/.github/workflows/new_contributor_pr.yml +++ b/.github/workflows/new_contributor_pr.yml @@ -15,6 +15,7 @@ jobs: if: github.repository == 'django/django' name: Hello new contributor runs-on: ubuntu-latest + timeout-minutes: 60 steps: # Pin to v1: https://github.com/actions/first-interaction/issues/369 - uses: actions/first-interaction@v1 diff --git a/.github/workflows/postgis.yml b/.github/workflows/postgis.yml index 4ea462ee446c..0970d02ab473 100644 --- a/.github/workflows/postgis.yml +++ b/.github/workflows/postgis.yml @@ -36,6 +36,7 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 diff --git a/.github/workflows/python_matrix.yml b/.github/workflows/python_matrix.yml index b3b28665113c..1139b19b2e80 100644 --- a/.github/workflows/python_matrix.yml +++ b/.github/workflows/python_matrix.yml @@ -20,6 +20,7 @@ jobs: runs-on: ubuntu-latest outputs: python_versions_output: ${{ steps.set-matrix.outputs.python_versions }} + timeout-minutes: 60 steps: - name: Checkout code uses: actions/checkout@v5 @@ -36,6 +37,7 @@ jobs: strategy: matrix: python-version: ${{ fromJson(needs.define-matrix.outputs.python_versions_output) }} + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 diff --git a/.github/workflows/schedule_tests.yml b/.github/workflows/schedule_tests.yml index 5679fbd77de2..ce313444e451 100644 --- a/.github/workflows/schedule_tests.yml +++ b/.github/workflows/schedule_tests.yml @@ -21,6 +21,7 @@ jobs: - '3.14' - '3.15-dev' name: Windows, SQLite, Python ${{ matrix.python-version }} + timeout-minutes: 60 continue-on-error: true steps: - name: Checkout @@ -42,6 +43,7 @@ jobs: pyc-only: runs-on: ubuntu-latest name: Byte-compiled Django with no source files (only .pyc files) + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -70,6 +72,7 @@ jobs: javascript-tests: runs-on: ubuntu-latest name: JavaScript tests + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -87,6 +90,7 @@ jobs: selenium-sqlite: runs-on: ubuntu-latest name: Selenium tests, SQLite + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -111,6 +115,7 @@ jobs: selenium-postgresql: runs-on: ubuntu-latest name: Selenium tests, PostgreSQL + timeout-minutes: 60 services: postgres: image: postgres:15-alpine @@ -156,6 +161,7 @@ jobs: server_side_bindings: [0, 1] runs-on: ubuntu-latest name: PostgreSQL Versions + timeout-minutes: 60 env: SERVER_SIDE_BINDING: ${{ matrix.server_side_bindings }} services: diff --git a/.github/workflows/schedules.yml b/.github/workflows/schedules.yml index 435921bccdeb..72ebf52f9c5a 100644 --- a/.github/workflows/schedules.yml +++ b/.github/workflows/schedules.yml @@ -14,6 +14,7 @@ jobs: runs-on: ubuntu-latest environment: schedules name: Trigger Full Build + timeout-minutes: 60 # Only trigger on the main Django repository if: (github.event_name == 'schedule' && github.repository == 'django/django') || (github.event_name != 'schedule') strategy: diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 82d99013715a..1180e9818dde 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -18,6 +18,7 @@ jobs: if: contains(join(github.event.pull_request.labels.*.name, '|'), 'screenshots') runs-on: ubuntu-latest name: Screenshots + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 diff --git a/.github/workflows/selenium.yml b/.github/workflows/selenium.yml index a07eb692a185..69de70ae598e 100644 --- a/.github/workflows/selenium.yml +++ b/.github/workflows/selenium.yml @@ -18,6 +18,7 @@ jobs: if: contains(github.event.pull_request.labels.*.name, 'selenium') runs-on: ubuntu-latest name: SQLite + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -43,6 +44,7 @@ jobs: if: contains(github.event.pull_request.labels.*.name, 'selenium') runs-on: ubuntu-latest name: PostgreSQL + timeout-minutes: 60 services: postgres: image: postgres:15-alpine diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c6321b1415f2..b709ed514540 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,6 +25,7 @@ jobs: python-version: - '3.14' name: Windows, SQLite, Python ${{ matrix.python-version }} + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 @@ -45,6 +46,7 @@ jobs: javascript-tests: runs-on: ubuntu-latest name: JavaScript tests + timeout-minutes: 60 steps: - name: Checkout uses: actions/checkout@v5 From 55af4749b9a48b2978e893e7d7be313c0b2abdb1 Mon Sep 17 00:00:00 2001 From: Cha Hwa Young Date: Mon, 13 Oct 2025 02:29:15 +0900 Subject: [PATCH 3/4] Fixed #31506 -- Clarified that ExpressionWrapper does not perform database casts. Added warning in DateField documentation about type differences when using timedelta on PostgreSQL and MySQL. Mentioned Cast() and integer arithmetic solutions. --- docs/ref/models/expressions.txt | 12 ++++++++++++ docs/ref/models/fields.txt | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt index 037d7520a380..098feeb0e192 100644 --- a/docs/ref/models/expressions.txt +++ b/docs/ref/models/expressions.txt @@ -37,6 +37,12 @@ determine the result's field type, such as complex expressions that mix field types. For example, adding a ``DecimalField()`` and a ``FloatField()`` requires an output field, like ``output_field=FloatField()``. +``output_field`` also allows using custom fields that perform type conversions +outside a specific model field context. For example, if you frequently need to +perform date arithmetic with ``timedelta``, you can create a custom field that +handles the conversion, ensuring consistent results across databases. See +:doc:`/howto/custom-model-fields`. + Some examples ============= @@ -575,6 +581,12 @@ available on other expressions. ``ExpressionWrapper`` is necessary when using arithmetic on ``F()`` expressions with different types as described in :ref:`using-f-with-annotations`. +.. admonition:: Database casting not performed + + ``ExpressionWrapper`` only sets the output field for the ORM and does not + perform any database-level casting. To ensure a specific type is returned + from the database, use :class:`~django.db.models.functions.Cast` instead. + ``JSONNull()`` expression ------------------------- diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 9aacbd29227f..492335504c75 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -831,6 +831,39 @@ exclusive. Any combination of these options will result in an error. instance, removing its time component. This is true for both storage and comparison. +.. warning:: + + On PostgreSQL and MySQL, arithmetic operations on a ``DateField`` with a + :class:`~datetime.timedelta` return a ``datetime`` instead of a ``date``. + This occurs because Python's ``timedelta`` is converted to SQL + ``INTERVAL``, and the SQL operation ``date +/- interval`` returns a + ``timestamp`` on these databases. + + To ensure a ``date`` result, use one of the following approaches. Either + explicitly cast the result to a date:: + + import datetime + from django.db.models import DateField, F + from django.db.models.functions import Cast + + qs = MyModel.objects.annotate( + previous_day=Cast( + F("date_field") - datetime.timedelta(days=1), + output_field=DateField(), + ) + ) + + Or on PostgreSQL only, use integer arithmetic to represent days:: + + from django.db.models import DateField, ExpressionWrapper, F + + qs = MyModel.objects.annotate( + previous_day=ExpressionWrapper( + F("date_field") - 1, # Subtract 1 day as integer + output_field=DateField(), + ) + ) + ``DateTimeField`` ----------------- From 818a620f0847d6d9f4f641114627a9537e5fea0e Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Thu, 20 Nov 2025 17:51:33 -0500 Subject: [PATCH 4/4] Refs #36619 -- Included third-party licenses with vendored eslint configuration files. --- eslint-recommended.js | 22 ++++++++++++++++++++++ globals.js | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/eslint-recommended.js b/eslint-recommended.js index 907c2bdcb762..66b183a512f4 100644 --- a/eslint-recommended.js +++ b/eslint-recommended.js @@ -1,5 +1,27 @@ /* https://github.com/eslint/eslint/blob/v9.36.0/packages/js/src/configs/eslint-recommended.js */ +/* +Copyright OpenJS Foundation and other contributors, + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + /** * @fileoverview Configuration applied when a user configuration extends from * eslint:recommended. diff --git a/globals.js b/globals.js index 8871f9e8b710..a57de514a883 100644 --- a/globals.js +++ b/globals.js @@ -1,5 +1,17 @@ /* https://github.com/sindresorhus/globals/blob/v16.4.0/globals.json */ +/* +MIT License + +Copyright (c) Sindre Sorhus (https://sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + "use strict";