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


Python exceptions.TemplateDoesNotExist方法代码示例

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


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

示例1: _validate_template_name_existence

# 需要导入模块: from django.template import exceptions [as 别名]
# 或者: from django.template.exceptions import TemplateDoesNotExist [as 别名]
def _validate_template_name_existence(template_name):
    try:
        get_template(template_name)
    except TemplateDoesNotExist:
        raise ImproperlyConfigured(
            'Template {template_name!r} does not exists'.format(
                template_name=template_name)) 
开发者ID:apragacz,项目名称:django-rest-registration,代码行数:9,代码来源:email.py

示例2: ServerError

# 需要导入模块: from django.template import exceptions [as 别名]
# 或者: from django.template.exceptions import TemplateDoesNotExist [as 别名]
def ServerError(request, template_name=ERROR_500_TEMPLATE_NAME):
    """
    Custom 500 handler to provide details when rendering 500.html.
    """
    try:
        template = loader.get_template(template_name)
    except TemplateDoesNotExist:
        return HttpResponseServerError(
            "<h1>Server Error (500)</h1>", content_type="text/html"
        )
    type_, error, _ = sys.exc_info()

    return HttpResponseServerError(
        template.render({"exception": str(type_), "error": error})
    ) 
开发者ID:respawner,项目名称:peering-manager,代码行数:17,代码来源:views.py

示例3: find_template_file

# 需要导入模块: from django.template import exceptions [as 别名]
# 或者: from django.template.exceptions import TemplateDoesNotExist [as 别名]
def find_template_file(template_name):
    """
    Return a full path to the specified template file.

    The key difference from the stock `find_template` is that we don't try to
    load a template in memory, because we'll deal with it ourselves.
    """
    for loader in _get_template_loaders():
        for origin in loader.get_template_sources(template_name, None):
            path = getattr(origin, 'name', origin)  # Django <1.9 compatibility
            if os.path.exists(path):
                return path
    raise TemplateDoesNotExist(template_name) 
开发者ID:alexmorozov,项目名称:templated-docs,代码行数:15,代码来源:__init__.py

示例4: test_server_error

# 需要导入模块: from django.template import exceptions [as 别名]
# 或者: from django.template.exceptions import TemplateDoesNotExist [as 别名]
def test_server_error(rf):
    request = rf.get("/")
    response = server_error(request)
    assert response.status_code == 500

    with pytest.raises(TemplateDoesNotExist):
        server_error(request, template_name="non-existing.html") 
开发者ID:mozilla,项目名称:telemetry-analysis-service,代码行数:9,代码来源:test_dashboard.py

示例5: test_wtm_include_marketing

# 需要导入模块: from django.template import exceptions [as 别名]
# 或者: from django.template.exceptions import TemplateDoesNotExist [as 别名]
def test_wtm_include_marketing(rf, site):
    token = Token(token_type=TOKEN_TYPE, contents='wtm_include "marketing" "test.html"')
    parser = Parser(tokens=[token])
    node = wtm_include(parser, token)

    with pytest.raises(TemplateDoesNotExist):
        request = rf.get(site.root_page.url)
        node.render(context=make_context({"request": request}))

        request.COOKIES = {"wtm": "marketing:false"}
        node.render(context=make_context({"request": request}))

        request.COOKIES = {"wtm": "marketing:true"}
        node.render(context=make_context({"request": request})) 
开发者ID:jberghoef,项目名称:wagtail-tag-manager,代码行数:16,代码来源:test_templatetags.py

示例6: common

# 需要导入模块: from django.template import exceptions [as 别名]
# 或者: from django.template.exceptions import TemplateDoesNotExist [as 别名]
def common(request):
    if request.is_ajax() or hasattr(request, 'versioning_scheme'):
        return {}

    from apps.extract.app_vars import STANDARD_LOCATORS, OPTIONAL_LOCATORS
    available_locators = set(STANDARD_LOCATORS.val) | set(OPTIONAL_LOCATORS.val)

    custom_main_menu_item_templates = []
    custom_task_menu_item_templates = []
    custom_apps = [i.replace('apps.', '') for i in settings.INSTALLED_APPS if i.startswith('apps.')]
    for app_name in custom_apps:
        try:
            mmi_template = get_template('%s/templates/%s' % (app_name, 'main_menu_item.html'))
            custom_main_menu_item_templates.append(mmi_template.template.name)
        except TemplateDoesNotExist:
            pass
        try:
            tmi_template = get_template('%s/templates/%s' % (app_name, 'task_menu_item.html'))
            custom_task_menu_item_templates.append(tmi_template.template.name)
        except TemplateDoesNotExist:
            pass

    return {'settings': settings,
            'custom_main_menu_item_templates': custom_main_menu_item_templates,
            'custom_task_menu_item_templates': custom_task_menu_item_templates,
            'available_locators': available_locators} 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:28,代码来源:context_processors.py


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