當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。