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


Python forms.WagtailAdminModelForm方法代码示例

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


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

示例1: test_get_form_for_model

# 需要导入模块: from wagtail.admin import forms [as 别名]
# 或者: from wagtail.admin.forms import WagtailAdminModelForm [as 别名]
def test_get_form_for_model(self):
        EventPageForm = get_form_for_model(EventPage, form_class=WagtailAdminPageForm)
        form = EventPageForm()

        # form should be a subclass of WagtailAdminModelForm
        self.assertTrue(issubclass(EventPageForm, WagtailAdminModelForm))
        # form should contain a title field (from the base Page)
        self.assertEqual(type(form.fields['title']), forms.CharField)
        # and 'date_from' from EventPage
        self.assertEqual(type(form.fields['date_from']), forms.DateField)
        # the widget should be overridden with AdminDateInput as per FORM_FIELD_OVERRIDES
        self.assertEqual(type(form.fields['date_from'].widget), AdminDateInput)

        # treebeard's 'path' field should be excluded
        self.assertNotIn('path', form.fields)

        # all child relations become formsets by default
        self.assertIn('speakers', form.formsets)
        self.assertIn('related_links', form.formsets) 
开发者ID:wagtail,项目名称:wagtail,代码行数:21,代码来源:test_edit_handlers.py

示例2: test_standard_edit_handler

# 需要导入模块: from wagtail.admin import forms [as 别名]
# 或者: from wagtail.admin.forms import WagtailAdminModelForm [as 别名]
def test_standard_edit_handler(self):
        edit_handler = get_snippet_edit_handler(StandardSnippet)
        form_class = edit_handler.get_form_class()
        self.assertTrue(issubclass(form_class, WagtailAdminModelForm))
        self.assertFalse(issubclass(form_class, FancySnippetForm)) 
开发者ID:wagtail,项目名称:wagtail,代码行数:7,代码来源:tests.py

示例3: test_fancy_edit_handler

# 需要导入模块: from wagtail.admin import forms [as 别名]
# 或者: from wagtail.admin.forms import WagtailAdminModelForm [as 别名]
def test_fancy_edit_handler(self):
        edit_handler = get_snippet_edit_handler(FancySnippet)
        form_class = edit_handler.get_form_class()
        self.assertTrue(issubclass(form_class, WagtailAdminModelForm))
        self.assertTrue(issubclass(form_class, FancySnippetForm)) 
开发者ID:wagtail,项目名称:wagtail,代码行数:7,代码来源:tests.py


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