Code of Conduct
Feature Description
Add a new DISABLED_MANAGEMENT_COMMANDS setting that allows projects to prevent selected management commands from being executed from the command line with django-admin or manage.py.
This is useful for deployments or restricted environments where risky commands such as flush or migrate should not be run manually, while still allowing programmatic usage through call_command().
Problem
It solves the problem of preventing accidental or unauthorized execution of risky management commands from the command line.
Request or proposal
request
Additional Details
No response
Implementation Suggestions
The implementation adds a new DISABLED_MANAGEMENT_COMMANDS setting with an empty list as the default value.
During command-line execution, ManagementUtility checks the active settings after processing early options such as --settings and --pythonpath. If the requested subcommand is listed in DISABLED_MANAGEMENT_COMMANDS, Django exits with a CommandError before loading or executing the command.
This check is limited to django-admin and manage.py command-line execution. django.core.management.call_command() is intentionally not affected, so projects and third-party code can still invoke commands programmatically when needed.
Code of Conduct
Feature Description
Add a new DISABLED_MANAGEMENT_COMMANDS setting that allows projects to prevent selected management commands from being executed from the command line with django-admin or manage.py.
This is useful for deployments or restricted environments where risky commands such as flush or migrate should not be run manually, while still allowing programmatic usage through call_command().
Problem
It solves the problem of preventing accidental or unauthorized execution of risky management commands from the command line.
Request or proposal
request
Additional Details
No response
Implementation Suggestions
The implementation adds a new DISABLED_MANAGEMENT_COMMANDS setting with an empty list as the default value.
During command-line execution, ManagementUtility checks the active settings after processing early options such as --settings and --pythonpath. If the requested subcommand is listed in DISABLED_MANAGEMENT_COMMANDS, Django exits with a CommandError before loading or executing the command.
This check is limited to django-admin and manage.py command-line execution. django.core.management.call_command() is intentionally not affected, so projects and third-party code can still invoke commands programmatically when needed.