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


Python RequestFactory.locale方法代码示例

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


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

示例1: render

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import locale [as 别名]
    def render(self, name, value, attrs=None):
        topics_and_subtopics = Topic.objects.all()
        topics = [t for t in topics_and_subtopics if t.parent_id is None]

        for topic in topics:
            self.process_topic(value, topic)

            topic.my_subtopics = [t for t in topics_and_subtopics
                                  if t.parent_id == topic.id]

            for subtopic in topic.my_subtopics:
                self.process_topic(value, subtopic)

        # Create a fake request to make jingo happy.
        req = RequestFactory()
        req.META = {}
        req.locale = settings.WIKI_DEFAULT_LANGUAGE

        return jingo.render_to_string(
            req,
            'wiki/includes/topics_widget.html',
            {
                'topics': topics,
                'name': name,
            })
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:27,代码来源:widgets.py

示例2: render_email

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import locale [as 别名]
def render_email(template, context):
    """Renders a template in the currently set locale."""
    req = RequestFactory()
    req.META = {}
    req.locale = translation.get_language()

    return jingo.render_to_string(req, template, context)
开发者ID:jasdeepdhillon13,项目名称:kitsune,代码行数:9,代码来源:email_utils.py

示例3: _render

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import locale [as 别名]
    def _render(locale):
        """Render an email in the given locale.

        Because of safe_translation decorator, if this fails,
        the function will be run again in English.
        """
        req = RequestFactory()
        req.META = {}
        req.locale = locale

        return jingo.render_to_string(req, template, context)
开发者ID:GabiThume,项目名称:kitsune,代码行数:13,代码来源:email_utils.py

示例4: setUp

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import locale [as 别名]
 def setUp(self):
     super(MockRequestTests, self).setUp()
     request = RequestFactory()
     request.locale = "en-US"
     self.request = request
开发者ID:bowmasters,项目名称:kitsune,代码行数:7,代码来源:test_templates.py

示例5: setUp

# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import locale [as 别名]
 def setUp(self):
     super(MockRequestTests, self).setUp()
     request = RequestFactory()
     request.GET = {}
     request.locale = 'en-US'
     self.request = request
开发者ID:strogo,项目名称:kitsune,代码行数:8,代码来源:test_templates.py


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