summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-04-26 16:37:57 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-04-30 10:48:30 +0200
commit6866c91b638de5368c18713fa851bfe56253ea55 (patch)
tree0d9003de07959a3bdb3be808fdff098dfa7c7fac
parenteb16c7260e573ec513d84cb586d96bdf508f3173 (diff)
Fixed #30418 -- Added --skip-checks management command option.
-rw-r--r--django/core/management/base.py11
-rw-r--r--docs/ref/django-admin.txt13
-rw-r--r--docs/releases/3.0.txt3
-rw-r--r--tests/user_commands/tests.py10
4 files changed, 34 insertions, 3 deletions
diff --git a/django/core/management/base.py b/django/core/management/base.py
index 0c3a981290..c725e5b75e 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -95,7 +95,7 @@ class DjangoHelpFormatter(HelpFormatter):
"""
show_last = {
'--version', '--verbosity', '--traceback', '--settings', '--pythonpath',
- '--no-color', '--force-color',
+ '--no-color', '--force-color', '--skip-checks',
}
def _reordered_actions(self, actions):
@@ -223,7 +223,7 @@ class BaseCommand:
requires_system_checks = True
# Arguments, common to all commands, which aren't defined by the argument
# parser.
- base_stealth_options = ('skip_checks', 'stderr', 'stdout')
+ base_stealth_options = ('stderr', 'stdout')
# Command-specific options not defined by the argument parser.
stealth_options = ()
@@ -286,6 +286,11 @@ class BaseCommand:
'--force-color', action='store_true',
help='Force colorization of the command output.',
)
+ if self.requires_system_checks:
+ parser.add_argument(
+ '--skip-checks', action='store_true',
+ help='Skip system checks.',
+ )
self.add_arguments(parser)
return parser
@@ -357,7 +362,7 @@ class BaseCommand:
if options.get('stderr'):
self.stderr = OutputWrapper(options['stderr'])
- if self.requires_system_checks and not options.get('skip_checks'):
+ if self.requires_system_checks and not options['skip_checks']:
self.check()
if self.requires_migrations_checks:
self.check_migrations()
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index b531978dd6..a269f6f8c6 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -1724,6 +1724,19 @@ Forces colorization of the command output if it would otherwise be disabled
as discussed in :ref:`syntax-coloring`. For example, you may want to pipe
colored output to another command.
+.. django-admin-option:: --skip-checks
+
+.. versionadded:: 3.0
+
+Skips running system checks prior to running the command. This option is only
+available if the
+:attr:`~django.core.management.BaseCommand.requires_system_checks` command
+attribute is set to ``True``.
+
+Example usage::
+
+ django-admin migrate --skip-checks
+
Extra niceties
==============
diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt
index e4a9789efb..66dfde0b5d 100644
--- a/docs/releases/3.0.txt
+++ b/docs/releases/3.0.txt
@@ -180,6 +180,9 @@ Management Commands
* :djadmin:`inspectdb` now introspects :class:`~django.db.models.OneToOneField`
when a foreign key has a unique or primary key constraint.
+* The new :option:`--skip-checks` option skips running system checks prior to
+ running the command.
+
Migrations
~~~~~~~~~~
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 2d1f8f834d..76991b1122 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -253,6 +253,16 @@ class CommandRunTests(AdminScriptTestCase):
self.assertNoOutput(err)
self.assertEqual(out.strip(), 'Set foo')
+ def test_skip_checks(self):
+ self.write_settings('settings.py', apps=['django.contrib.staticfiles', 'user_commands'], sdict={
+ # (staticfiles.E001) The STATICFILES_DIRS setting is not a tuple or
+ # list.
+ 'STATICFILES_DIRS': '"foo"',
+ })
+ out, err = self.run_manage(['set_option', '--skip-checks', '--set', 'foo'])
+ self.assertNoOutput(err)
+ self.assertEqual(out.strip(), 'Set foo')
+
class UtilsTests(SimpleTestCase):