本文整理匯總了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))