diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2024-11-23 11:41:14 -0500 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-12-11 17:25:47 +0100 |
| commit | 2ce4545de1791d6ed2405cb0657401e179bc5357 (patch) | |
| tree | 6c4a837bfd9e1b0f19e06edb50f7dd99ca2b575b /docs | |
| parent | a16eedcf9c69d8a11d94cac1811018c5b996d491 (diff) | |
Fixed #35920 -- Observed requires_system_checks in migrate and runserver.
Before, the full suite of system checks was run by these commands
regardless if requires_system_checks had been overridden.
Co-authored-by: Simon Charette <charette.s@gmail.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/howto/custom-management-commands.txt | 15 | ||||
| -rw-r--r-- | docs/releases/5.2.txt | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt index d3775905d3..de6c38c1e0 100644 --- a/docs/howto/custom-management-commands.txt +++ b/docs/howto/custom-management-commands.txt @@ -319,6 +319,21 @@ the :meth:`~BaseCommand.handle` method must be implemented. checks, and list of database aliases in the ``databases`` to run database related checks against them. +.. method:: BaseCommand.get_check_kwargs(options) + + .. versionadded:: 5.2 + + Supplies kwargs for the call to :meth:`check`, including transforming the + value of :attr:`requires_system_checks` to the ``tag`` kwarg. + + Override this method to change the values supplied to :meth:`check`. For + example, to opt into database related checks you can override + ``get_check_kwargs()`` as follows:: + + def get_check_kwargs(self, options): + kwargs = super().get_check_kwargs(options) + return {**kwargs, "databases": [options["database"]]} + .. _ref-basecommand-subclasses: ``BaseCommand`` subclasses diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt index 907159e36d..5e692c0345 100644 --- a/docs/releases/5.2.txt +++ b/docs/releases/5.2.txt @@ -279,6 +279,10 @@ Management Commands ``Command.autodetector`` attribute for subclasses to override in order to use a custom autodetector class. +* The new :meth:`.BaseCommand.get_check_kwargs` method can be overridden in + custom commands to control the running of system checks, e.g. to opt into + database-dependent checks. + Migrations ~~~~~~~~~~ |
