本文整理汇总了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)
示例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))
示例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))