diff options
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 ~~~~~~~~~~ |
