本文整理匯總了Python中django.core.management.validation.get_validation_errors方法的典型用法代碼示例。如果您正苦於以下問題:Python validation.get_validation_errors方法的具體用法?Python validation.get_validation_errors怎麽用?Python validation.get_validation_errors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.core.management.validation
的用法示例。
在下文中一共展示了validation.get_validation_errors方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: validate
# 需要導入模塊: from django.core.management import validation [as 別名]
# 或者: from django.core.management.validation import get_validation_errors [as 別名]
def validate(self, app=None, display_num_errors=False):
"""
Validates the given app, raising CommandError for any errors.
If app is None, then this will validate all installed apps.
"""
from django.core.management.validation import get_validation_errors
s = StringIO()
num_errors = get_validation_errors(s, app)
if num_errors:
s.seek(0)
error_text = s.read()
raise CommandError("One or more models did not validate:\n%s" % error_text)
if display_num_errors:
self.stdout.write("%s error%s found" % (num_errors, '' if num_errors == 1 else 's'))
示例2: make_wsgi_application
# 需要導入模塊: from django.core.management import validation [as 別名]
# 或者: from django.core.management.validation import get_validation_errors [as 別名]
def make_wsgi_application():
# validate models
s = StringIO()
if get_validation_errors(s):
s.seek(0)
error = s.read()
msg = "One or more models did not validate:\n%s" % error
print(msg, file=sys.stderr)
sys.stderr.flush()
sys.exit(1)
translation.activate(settings.LANGUAGE_CODE)
if django14:
return get_internal_wsgi_application()
return WSGIHandler()