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


Python FormConfig.configure方法代码示例

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


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

示例1: test_stacked_config

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import configure [as 别名]
    def test_stacked_config(self):
        form = RegistrationForm()
        config = FormConfig()

        config.push()
        config.configure(
            'widget', widgets.Textarea(),
            filter=ConfigFilter("CharField"),
        )

        config.push()
        config.configure(
            'widget', widgets.HiddenInput(),
            filter=ConfigFilter('short_biography'),
        )

        widget = config.retrieve('widget', bound_field=form['short_biography'])
        self.assertEqual(widget.__class__, widgets.HiddenInput)

        config.pop()
        widget = config.retrieve('widget', bound_field=form['short_biography'])
        self.assertEqual(widget.__class__, widgets.Textarea)

        config.pop()
        widget = config.retrieve('widget', bound_field=form['short_biography'])
        self.assertEqual(widget.__class__, widgets.TextInput)
开发者ID:LaMustax,项目名称:django-floppyforms,代码行数:28,代码来源:rendering.py

示例2: test_change_widget

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import configure [as 别名]
    def test_change_widget(self):
        form = SimpleForm()
        config = FormConfig()
        config.configure('widget', forms.PasswordInput(), filter=ConfigFilter(form['name']))

        self.assertHTMLEqual(render("""{% form myform using %}
            {% formfield form.name %}
        {% endform %}""", {'myform': form}, config), """<input type="password" name="name" id="id_name" />""")
开发者ID:jmichalski,项目名称:django-floppyforms,代码行数:10,代码来源:templatetags.py

示例3: test_field_filter_works_on_subclasses

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import configure [as 别名]
    def test_field_filter_works_on_subclasses(self):
        form = RegistrationForm()
        config = FormConfig()

        config.configure("widget", widgets.HiddenInput(), filter=ConfigFilter("IntegerField"))

        widget = config.retrieve("widget", bound_field=form["age"])
        self.assertEqual(widget.__class__, widgets.HiddenInput)
开发者ID:andrewsmedina,项目名称:django-floppyforms,代码行数:10,代码来源:test_rendering.py

示例4: test_filter_for_field_class_name

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import configure [as 别名]
    def test_filter_for_field_class_name(self):
        form = RegistrationForm()

        config = FormConfig()
        config.configure('widget', widgets.TextInput(), filter=ConfigFilter('CharField'))

        widget = config.retrieve('widget', bound_field=form['comment'])
        self.assertEqual(widget.__class__, widgets.TextInput)

        widget = config.retrieve('widget', bound_field=form['name'])
        self.assertEqual(widget.__class__, widgets.TextInput)
开发者ID:NetAngels,项目名称:django-floppyforms,代码行数:13,代码来源:rendering.py

示例5: test_retrieve_all

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import configure [as 别名]
    def test_retrieve_all(self):
        config = FormConfig()

        config.configure('number', 1)
        config.configure('number', 2)
        self.assertEqual(list(config.retrieve_all('number')), [2, 1])

        config.configure('number', 4, filter=lambda nr=None, **kwargs: nr == 'four')
        self.assertEqual(list(config.retrieve_all('number')), [2, 1])
        self.assertEqual(list(config.retrieve_all('number', nr='four')), [4, 2, 1])

        config.push()
        config.configure('number', 5, filter=lambda nr=None, **kwargs: nr == 'five')
        self.assertEqual(list(config.retrieve_all('number')), [2, 1])
        self.assertEqual(list(config.retrieve_all('number', nr='five')), [5, 2, 1])

        config.configure('number', -1)
        self.assertEqual(list(config.retrieve_all('number')), [-1, 2, 1])
        self.assertEqual(list(config.retrieve_all('number', nr='four')), [-1, 4, 2, 1])
        self.assertEqual(list(config.retrieve_all('number', nr='five')), [-1, 5, 2, 1])

        config.pop()
        self.assertEqual(list(config.retrieve_all('number')), [2, 1])
        self.assertEqual(list(config.retrieve_all('number', nr='four')), [4, 2, 1])
        self.assertEqual(list(config.retrieve_all('number', nr='five')), [2, 1])
开发者ID:LaMustax,项目名称:django-floppyforms,代码行数:27,代码来源:rendering.py

示例6: test_filter_for_name_object

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import configure [as 别名]
    def test_filter_for_name_object(self):
        form = RegistrationForm()

        config = FormConfig()
        config.configure('widget', widgets.Textarea(), filter=ConfigFilter('object'))

        widget = config.retrieve('widget', bound_field=form['email'])
        self.assertEqual(widget.__class__, widgets.EmailInput)

        widget = config.retrieve('widget', bound_field=form['name'])
        self.assertEqual(widget.__class__, widgets.TextInput)

        widget = config.retrieve('widget', bound_field=form['comment'])
        self.assertEqual(widget.__class__, widgets.Textarea)
开发者ID:NetAngels,项目名称:django-floppyforms,代码行数:16,代码来源:rendering.py

示例7: test_retrieve_for_multiple_valid_values

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import configure [as 别名]
    def test_retrieve_for_multiple_valid_values(self):
        form = RegistrationForm()
        config = FormConfig()

        config.configure("widget", widgets.Textarea(), filter=ConfigFilter("CharField"))
        config.configure("widget", widgets.HiddenInput(), filter=ConfigFilter("short_biography"))

        widget = config.retrieve("widget", bound_field=form["name"])
        self.assertEqual(widget.__class__, widgets.Textarea)
        widget = config.retrieve("widget", bound_field=form["comment"])
        self.assertEqual(widget.__class__, widgets.Textarea)

        # we get HiddenInput since this was configured last, even the Textarea
        # config applies to ``short_biography``
        widget = config.retrieve("widget", bound_field=form["short_biography"])
        self.assertEqual(widget.__class__, widgets.HiddenInput)
开发者ID:andrewsmedina,项目名称:django-floppyforms,代码行数:18,代码来源:test_rendering.py


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