mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Skip model validation when models are known good.
In some situations Django calls model validation when the models are already known good. This is most visible in tests, which use flush and loaddata commands. This resulted in around 10% overhead when running tests under sqlite.
This commit is contained in:
@@ -198,9 +198,9 @@ class BaseCommand(object):
|
||||
"""
|
||||
Try to execute this command, performing model validation if
|
||||
needed (as controlled by the attribute
|
||||
``self.requires_model_validation``). If the command raises a
|
||||
``CommandError``, intercept it and print it sensibly to
|
||||
stderr.
|
||||
``self.requires_model_validation``, except if force-skipped). If the
|
||||
command raises a ``CommandError``, intercept it and print it sensibly
|
||||
to stderr.
|
||||
"""
|
||||
show_traceback = options.get('traceback', False)
|
||||
|
||||
@@ -226,7 +226,7 @@ class BaseCommand(object):
|
||||
try:
|
||||
self.stdout = options.get('stdout', sys.stdout)
|
||||
self.stderr = options.get('stderr', sys.stderr)
|
||||
if self.requires_model_validation:
|
||||
if self.requires_model_validation and not options.get('skip_validation'):
|
||||
self.validate()
|
||||
output = self.handle(*args, **options)
|
||||
if output:
|
||||
|
||||
Reference in New Issue
Block a user