| Age | Commit message (Collapse) | Author |
|
Thank you Mike Edmunds for the review.
|
|
QUERY (RFC 10008) is a safe, idempotent method that carries the query in
the request content rather than in the URI's query component. Treat it as
safe throughout: exempt it from CSRF protection, evaluate request
preconditions as for GET, accept it in require_safe(), and dispatch it
from View. Query content is available as HttpRequest.body and is not
parsed into HttpRequest.POST.
Caching is left for a follow-up. Per RFC 10008 Section 2.7 the cache key
for a QUERY request must incorporate the request content, which the cache
middleware and cache_page() don't do, so they continue to ignore QUERY.
Thanks Ben Atkinson, Jonathan Biemond, and Jacob Walls for reviews.
|
|
Replaced bare `async for` over a not-locally-defined async iterable with
`async with (maybe_)aclosing(aiter(...)) as it: async for item in it:` at
every consumption site, so the iterator's aclose() runs deterministically
when the consumer exits — instead of being deferred to asyncio's asyncgen
finalizer hook.
Added django.utils.asyncio.maybe_aclosing as a small wrapper that uses
contextlib.aclosing when the iterator has aclose() and contextlib.nullcontext
otherwise (for caller-supplied iterators that may only implement __aiter__
and __anext__).
Sites:
- contrib/auth/backends.py:_aget_permissions (aclosing)
- core/paginator.py:AsyncPage.__aiter__ (maybe_aclosing)
- core/paginator.py:AsyncPage.aget_object_list (maybe_aclosing)
- db/models/query.py:QuerySet.aiterator (aclosing, hoisted across both
prefetch and no-prefetch branches)
- http/response.py:StreamingHttpResponse.streaming_content awrapper
(maybe_aclosing)
- http/response.py:StreamingHttpResponse.__iter__ to_list (maybe_aclosing)
- http/response.py:StreamingHttpResponse.__aiter__ (aclosing)
- shortcuts.py:aget_list_or_404 (aclosing)
- test/client.py:aclosing_iterator_wrapper (maybe_aclosing)
- utils/text.py:acompress_sequence (maybe_aclosing)
|
|
Updated references to RemovedInDjango70Warning to use the new warning,
and adjusted references to "Django 7.0" to "Django 2028".
RemovedInDjango70Warning remains importable as an alias of the same
class, so existing warning filters and except clauses in third-party
code keep working across the rename.
|
|
testing.
|
|
Language codes longer than 500 characters are now rejected before the
cached lookup, so they are no longer retained as cache keys consuming
memory from each process.
Thanks Jaeyoung Jang for the report, and Sarah Boyce for reviews.
|
|
workers.
This prevents newly spawned workers from attempting to access nonexistent
clones.
Thanks James Bligh for the review.
|
|
encode_multipart().
When data is a MultiValueDict, encode_multipart() now uses data.lists()
instead of data.items() to preserve all values per key. Previously, only
the last value for each key was encoded, silently dropping form field
values when a file upload shared the same name.
|
|
|
|
(a)force_login().
Co-authored-by: Mykhailo Havelia <Arfey17.mg@gmail.com>
|
|
See DEP 0018.
Added:
* MAILERS setting.
* django.core.mail.mailers dict-like EmailBackend factory.
* `using` argument to mail sending APIs.
* `sent_using` attribute to mail.outbox messages in locmem backend.
* MAILERS in startproject settings template, set to console backend.
* AdminLogHandler.using argument.
* BrokenLinkEmailsMiddleware.send_mail() method.
Updated:
* BaseEmailBackend to track the MAILERS alias used to construct it, and
to report errors for unknown kwargs (OPTIONS).
* EmailBackend implementations to initialize from kwargs (OPTIONS) only
when MAILERS is being used.
* smtp.EmailBackend to require `host` option and to default `port`
option based on SSL/TLS options.
* SimpleTestCase setup to substitute the locmem backend for all defined
MAILERS configurations.
* Django's tests that send mail to define MAILERS.
Deprecated:
* EMAIL_BACKEND and other backend-related EMAIL_* settings.
* mail.get_connection().
* The `connection`, `fail_silently`, `auth_user`, and `auth_password`
arguments to mail functions.
* The EmailMessage.connection attribute.
* BaseEmailBackend support for `fail_silently`. Backends that support
fail_silently (SMTP, console, file) now implement it directly.
* AdminEmailHandler.email_backend argument.
Removed undocumented features without deprecation:
* EmailMessage.get_connection() method. (send() now raises an error if a
subclass has attempted to override it.)
* EmailMessage.send() no longer sets self.connection to the connection
used for sending. (It still _uses_ a pre-existing self.connection.)
* AdminEmailHandler.connection() method. (Init now raises an error if a
subclass has attempted to override it.)
Thanks to Natalia Bidart for shepherding DEP 0018 and for extensive
reviews and suggestions on the implementation.
Thanks to Jacob Rief for the initial implementation and multiple
iterations while refining the design.
Co-authored-by: Jacob Rief <jacob.rief@gmail.com>
|
|
|
|
Thanks Tarek Nakkouch for the report and Jake Howard and Natalia Bidart
for reviews.
|
|
terminate() shouldn't assume the main server was started. (A deadlock
from mishandling of in-memory SQLite databases may have occurred.)
|
|
tests.
Thanks JaeHyuck Sa and Jake Howard for the reviews.
|
|
streaming responses.
|
|
on test client.
|
|
As Python 3.12 is now the floor, we can drop the shims and
use the `inspect` module.
|
|
https://github.com/psf/black/releases/tag/26.1.0
|
|
|
|
|
|
Thanks Natalia Bidart for the review.
|
|
django_test_expected_failures.
|
|
Running system checks in workers must happen after database aliases
are set up.
Regression in 606fc352799e372928fa2c978ab99f0fb6d6017c.
|
|
Thanks Javier Buzzi and Adam Johnson for reviews.
Co-authored-by: Simon Charette <charette.s@gmail.com>
|
|
Workers created by ParallelTestSuite were not running system
checks in the spawn multiprocessing mode. In general this is
fine, but system checks can have side effects expected by tests.
This patch runs system checks inside of _init_worker, which is
only called by ParallelTestSuite.
|
|
PartialTemplate.
Previously, assertTemplateUsed only matched partial names, ignoring
the template origin. This caused assertions on partials specified by
origin ("template.html#partial") to fail. Refs #36410.
|
|
Language.
Introduced `{% partialdef %}` and `{% partial %}` template tags to
define and render reusable named fragments within a template file.
Partials can also be accessed using the `template_name#partial_name`
syntax via `get_template()`, `render()`, `{% include %}`, and other
template-loading tools.
Adjusted `get_template()` behavior to support partial resolution, with
appropriate error handling for invalid names and edge cases. Introduced
`PartialTemplate` to encapsulate partial rendering behavior.
Includes tests and internal refactors to support partial context
binding, exception reporting, and tag validation.
Co-authored-by: Carlton Gibson <carlton@noumenal.es>
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
|
|
|
|
Rewrapped long docstrings and block comments to 79 characters + newline
using script from https://github.com/medmunds/autofix-w505.
|
|
Manually reformatted some long docstrings and comments that would be
damaged by the to-be-applied autofixer script, in cases where editorial
judgment seemed necessary for style or wording changes.
|
|
|
|
Performance regression in 1dae65dc63ae84be5002c37b4ddae0b9220e8808.
Thanks to Adam Johnson for the report.
|
|
ContentSecurityPolicyMiddleware.
Replaced the custom CSP middleware previously used in the admin's
AdminSeleniumTestCase with the official ContentSecurityPolicyMiddleware.
This change ensures alignment with Django's built-in CSP support.
Also updates the test logic to inspect browser console logs to assert
that no CSP violations are triggered during Selenium admin tests.
|
|
Follow up to f5df7ed7e62585c7d0289a88a327dab8d608efcf.
|
|
This was added in 46c7707e50400e237cbd774a31ad801669ca3905 but is
obsolete now that gis_tests are discovered separately. It's
error-prone to ignore mistyped names.
|
|
Thanks to Jacob Walls for the report and previous iterations of this
fix, to Simon Charette for the logging formatter idea, and to Tim Graham
for testing and ensuring that 3rd party backends remain compatible.
This partially reverts d8f093908c504ae0dbc39d3f5231f7d7920dde37.
Refs #36112, #35448.
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
|
|
|
|
|
|
Given there are no longer any internal usages of serialize=True and it
poses a risk to non-test databases integrity it seems appropriate to
deprecate it.
|
|
While the top-level objects fed to serialization are bound to the test
database being created nothing prevents code invoked during
serialization from performing queries against other connections entries
that haven't been swapped yet.
The reported example of that is a database router directing all reads to
a test mirror for a set of models involving auto-created many-to-many
fields. It might be tempting to address the many-to-many field case but
this a symptom of a larger problem where the test framework yields the
flow execution to user code that could interact with non-test databases
in unexpected ways.
Deferring test database fixture serialization until the point where all
connections entries have been swapped for their test equivalent ensures
that no code triggered during serialization can interact with non-test
databases.
Thanks Jake Howard for the report and Jacob Walls for the initial
investigation.
|
|
|
|
Also adds DatabaseOperations.format_debug_sql() hook for backends
(e.g. NoSQL) to customize formatting.
|
|
on Python 3.13+.
|
|
|
|
|
|
|
|
HttpResponse.text property.
Signed-off-by: SaJH <wogur981208@gmail.com>
|
|
TransactionTestCase.setUpClass().
|
|
|