當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。