当前位置: 首页>>代码示例>>Python>>正文


Python BaseCommand.check方法代码示例

本文整理汇总了Python中django.core.management.base.BaseCommand.check方法的典型用法代码示例。如果您正苦于以下问题:Python BaseCommand.check方法的具体用法?Python BaseCommand.check怎么用?Python BaseCommand.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.core.management.base.BaseCommand的用法示例。


在下文中一共展示了BaseCommand.check方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate_models

# 需要导入模块: from django.core.management.base import BaseCommand [as 别名]
# 或者: from django.core.management.base.BaseCommand import check [as 别名]
    def validate_models(self):
        import django
        try:
            django_setup = django.setup
        except AttributeError:
            pass
        else:
            django_setup()
        s = io.StringIO()
        try:
            from django.core.management.validation import get_validation_errors
        except ImportError:
            from django.core.management.base import BaseCommand
            cmd = BaseCommand()
            try:
                # since django 1.5
                from django.core.management.base import OutputWrapper
                cmd.stdout = OutputWrapper(sys.stdout)
                cmd.stderr = OutputWrapper(sys.stderr)
            except ImportError:
                cmd.stdout, cmd.stderr = sys.stdout, sys.stderr

            cmd.check()
        else:
            num_errors = get_validation_errors(s, None)
            if num_errors:
                raise RuntimeError(
                    'One or more Django models did not validate:\n{0}'.format(
                        s.getvalue()))
开发者ID:aclowes,项目名称:celery,代码行数:31,代码来源:django.py

示例2: make_wsgi_application

# 需要导入模块: from django.core.management.base import BaseCommand [as 别名]
# 或者: from django.core.management.base.BaseCommand import check [as 别名]
def make_wsgi_application():
    # validate models
    s = StringIO()
    import django
    from django.core.management.base import BaseCommand
    django.setup()
    cmd = BaseCommand()
    import sys
    cmd.stdout, cmd.stderr = sys.stdout, sys.stderr
    cmd.check()
    translation.activate(settings.LANGUAGE_CODE)
    if django14:
        return get_internal_wsgi_application()
    return WSGIHandler()
开发者ID:nickatnight,项目名称:srvrdj,代码行数:16,代码来源:wsgi.py

示例3: validate_models

# 需要导入模块: from django.core.management.base import BaseCommand [as 别名]
# 或者: from django.core.management.base.BaseCommand import check [as 别名]
 def validate_models(self):
     s = io.StringIO()
     try:
         from django.core.management.validation import get_validation_errors
     except ImportError:
         import django
         from django.core.management.base import BaseCommand
         django.setup()
         cmd = BaseCommand()
         cmd.stdout, cmd.stderr = sys.stdout, sys.stderr
         cmd.check()
     else:
         num_errors = get_validation_errors(s, None)
         if num_errors:
             raise RuntimeError(
                 'One or more Django models did not validate:\n{0}'.format(
                     s.getvalue()))
开发者ID:Aliced3645,项目名称:celery,代码行数:19,代码来源:django.py


注:本文中的django.core.management.base.BaseCommand.check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。