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


Python settings.TEMPLATE_DEBUG属性代码示例

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


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

示例1: _pre_setup

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def _pre_setup(self):
        """Disable transaction methods, and clear some globals."""
        # Repeat stuff from TransactionTestCase, because I'm not calling its
        # _pre_setup, because that would load fixtures again.
        cache.cache.clear()
        settings.TEMPLATE_DEBUG = settings.DEBUG = False


        self.client = self.client_class()
        #self._fixture_setup()
        self._urlconf_setup()
        mail.outbox = []

        # Clear site cache in case somebody's mutated Site objects and then
        # cached the mutated stuff:
        from django.contrib.sites.models import Site
        Site.objects.clear_cache() 
开发者ID:sfu-fas,项目名称:coursys,代码行数:19,代码来源:testcase.py

示例2: extra_context

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def extra_context(self):
        """Add site_name to context
        """
        from django.conf import settings

        return {
            "site_name": (lambda r: settings.LEONARDO_SITE_NAME
                          if getattr(settings, 'LEONARDO_SITE_NAME', '') != ''
                          else settings.SITE_NAME),
            "debug": lambda r: settings.TEMPLATE_DEBUG
        } 
开发者ID:django-leonardo,项目名称:django-leonardo,代码行数:13,代码来源:__init__.py

示例3: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def __init__(self, template_string, origin=None,
                 name='<Unknown Template>'):
        try:
            template_string = force_text(template_string)
        except UnicodeDecodeError:
            raise TemplateEncodingError("Templates can only be constructed "
                                        "from unicode or UTF-8 strings.")
        if settings.TEMPLATE_DEBUG and origin is None:
            origin = StringOrigin(template_string)
        self.nodelist = compile_string(template_string, origin)
        self.name = name 
开发者ID:blackye,项目名称:luscan-devel,代码行数:13,代码来源:base.py

示例4: compile_string

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def compile_string(template_string, origin):
    "Compiles template_string into NodeList ready for rendering"
    if settings.TEMPLATE_DEBUG:
        from django.template.debug import DebugLexer, DebugParser
        lexer_class, parser_class = DebugLexer, DebugParser
    else:
        lexer_class, parser_class = Lexer, Parser
    lexer = lexer_class(template_string, origin)
    parser = parser_class(lexer.tokenize())
    return parser.parse() 
开发者ID:blackye,项目名称:luscan-devel,代码行数:12,代码来源:base.py

示例5: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def __init__(self, template_path, *args, **kwargs):
        super(ConstantIncludeNode, self).__init__(*args, **kwargs)
        try:
            t = get_template(template_path)
            self.template = t
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            self.template = None 
开发者ID:blackye,项目名称:luscan-devel,代码行数:11,代码来源:loader_tags.py

示例6: render

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def render(self, context):
        try:
            template_name = self.template_name.resolve(context)
            template = get_template(template_name)
            return self.render_template(template, context)
        except:
            if settings.TEMPLATE_DEBUG:
                raise
            return '' 
开发者ID:blackye,项目名称:luscan-devel,代码行数:11,代码来源:loader_tags.py

示例7: make_origin

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def make_origin(display_name, loader, name, dirs):
    if settings.TEMPLATE_DEBUG and display_name:
        return LoaderOrigin(display_name, loader, name, dirs)
    else:
        return None 
开发者ID:blackye,项目名称:luscan-devel,代码行数:7,代码来源:loader.py

示例8: _get_debug_settings

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def _get_debug_settings():
    return {
        'debug': settings.DEBUG,
        'template': settings.TEMPLATE_DEBUG,
        'javascript': settings.JAVASCRIPT_DEBUG,
        'sql': settings.SQL_DEBUG,
        'sql_queries': _get_sql_queries(),
    } 
开发者ID:erigones,项目名称:esdc-ce,代码行数:10,代码来源:context_processors.py

示例9: render

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def render(self, context):
        """
        Load in the gizmos to be rendered
        """
        try:
            self._load_gizmos_rendered(context)
        except Exception as e:
            if settings.TEMPLATE_DEBUG:
                raise e

        return '' 
开发者ID:tethysplatform,项目名称:tethys,代码行数:13,代码来源:tethys_gizmos.py

示例10: templates

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import TEMPLATE_DEBUG [as 别名]
def templates(self):
        if self._templates is None:
            self._templates = settings.TEMPLATES

        if not self._templates:
            warnings.warn(
                "You haven't defined a TEMPLATES setting. You must do so "
                "before upgrading to Django 1.10. Otherwise Django will be "
                "unable to load templates.", RemovedInDjango110Warning)
            self._templates = [
                {
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'DIRS': settings.TEMPLATE_DIRS,
                    'OPTIONS': {
                        'allowed_include_roots': settings.ALLOWED_INCLUDE_ROOTS,
                        'context_processors': settings.TEMPLATE_CONTEXT_PROCESSORS,
                        'debug': settings.TEMPLATE_DEBUG,
                        'loaders': settings.TEMPLATE_LOADERS,
                        'string_if_invalid': settings.TEMPLATE_STRING_IF_INVALID,
                    },
                },
            ]

        templates = OrderedDict()
        backend_names = []
        for tpl in self._templates:
            tpl = tpl.copy()
            try:
                # This will raise an exception if 'BACKEND' doesn't exist or
                # isn't a string containing at least one dot.
                default_name = tpl['BACKEND'].rsplit('.', 2)[-2]
            except Exception:
                invalid_backend = tpl.get('BACKEND', '<not defined>')
                raise ImproperlyConfigured(
                    "Invalid BACKEND for a template engine: {}. Check "
                    "your TEMPLATES setting.".format(invalid_backend))

            tpl.setdefault('NAME', default_name)
            tpl.setdefault('DIRS', [])
            tpl.setdefault('APP_DIRS', False)
            tpl.setdefault('OPTIONS', {})

            templates[tpl['NAME']] = tpl
            backend_names.append(tpl['NAME'])

        counts = Counter(backend_names)
        duplicates = [alias for alias, count in counts.most_common() if count > 1]
        if duplicates:
            raise ImproperlyConfigured(
                "Template engine aliases aren't unique, duplicates: {}. "
                "Set a unique NAME for each engine in settings.TEMPLATES."
                .format(", ".join(duplicates)))

        return templates 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:56,代码来源:utils.py


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