本文整理汇总了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()