• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python edit_handlers.get_form_for_model函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wagtail.wagtailadmin.edit_handlers.get_form_for_model函数的典型用法代码示例。如果您正苦于以下问题:Python get_form_for_model函数的具体用法?Python get_form_for_model怎么用?Python get_form_for_model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_direct_form_field_overrides

    def test_direct_form_field_overrides(self):
        # Test that field overrides defined through DIRECT_FORM_FIELD_OVERRIDES
        # are applied

        SimplePageForm = get_form_for_model(SimplePage)
        simple_form = SimplePageForm()
        # plain TextFields should use AdminAutoHeightTextInput as the widget
        self.assertEqual(type(simple_form.fields['content'].widget), AdminAutoHeightTextInput)

        # This override should NOT be applied to subclasses of TextField such as
        # RichTextField - they should retain their default widgets
        EventPageForm = get_form_for_model(EventPage)
        event_form = EventPageForm()
        self.assertEqual(type(event_form.fields['body'].widget), RichTextArea)
开发者ID:Fluxflashor,项目名称:wagtail,代码行数:14,代码来源:test_edit_handlers.py


示例2: setUp

    def setUp(self):
        self.EventPageForm = get_form_for_model(
            EventPage, form_class=WagtailAdminPageForm, formsets=[])
        self.event = EventPage(title='Abergavenny sheepdog trials',
                               date_from=date(2014, 7, 20), date_to=date(2014, 7, 21))

        self.EndDatePanel = FieldPanel('date_to', classname='full-width').bind_to_model(EventPage)
开发者ID:DjangoBD,项目名称:wagtail,代码行数:7,代码来源:test_edit_handlers.py


示例3: test_get_form_for_model_with_widget_overides_by_class

    def test_get_form_for_model_with_widget_overides_by_class(self):
        EventPageForm = get_form_for_model(
            EventPage, form_class=WagtailAdminPageForm,
            widgets={'date_from': forms.PasswordInput})
        form = EventPageForm()

        self.assertEqual(type(form.fields['date_from']), forms.DateField)
        self.assertEqual(type(form.fields['date_from'].widget), forms.PasswordInput)
开发者ID:DjangoBD,项目名称:wagtail,代码行数:8,代码来源:test_edit_handlers.py


示例4: setUp

    def setUp(self):
        self.form_page = make_form_page()

        self.FormPageForm = get_form_for_model(
            FormPage, form_class=WagtailAdminPageForm
        )

        submissions_panel = FormSubmissionsPanel().bind_to_model(FormPage)

        self.panel = submissions_panel(self.form_page, self.FormPageForm())
开发者ID:alexgleason,项目名称:wagtail,代码行数:10,代码来源:tests.py


示例5: setUp

    def setUp(self):
        self.EventPageForm = get_form_for_model(
            EventPage, form_class=WagtailAdminPageForm, formsets=[])
        self.event = EventPage(title='Abergavenny sheepdog trials',
                               date_from=date(2014, 7, 20), date_to=date(2014, 7, 21))

        self.DatesPanel = FieldRowPanel([
            FieldPanel('date_from', classname='col4'),
            FieldPanel('date_to', classname='coltwo'),
        ]).bind_to_model(EventPage)
开发者ID:chrxr,项目名称:wagtail,代码行数:10,代码来源:test_edit_handlers.py


示例6: test_get_form_for_model

 def test_get_form_for_model(self):
     form = get_form_for_model(self.FakeClass,
                               fields=[],
                               exclude=[self.mock_exclude],
                               formsets=['baz'],
                               exclude_formsets=['quux'],
                               widgets=['bacon'])
     self.assertEqual(form.Meta.exclude, [self.mock_exclude])
     self.assertEqual(form.Meta.formsets, ['baz'])
     self.assertEqual(form.Meta.exclude_formsets, ['quux'])
     self.assertEqual(form.Meta.widgets, ['bacon'])
开发者ID:0b3r,项目名称:wagtail,代码行数:11,代码来源:test_edit_handlers.py


示例7: test_get_form_for_model_with_specific_fields

    def test_get_form_for_model_with_specific_fields(self):
        EventPageForm = get_form_for_model(EventPage, fields=['date_from'], formsets=['speakers'])
        form = EventPageForm()

        # form should contain date_from but not title
        self.assertEqual(type(form.fields['date_from']), forms.DateField)
        self.assertEqual(type(form.fields['date_from'].widget), AdminDateInput)
        self.assertNotIn('title', form.fields)

        # formsets should include speakers but not related_links
        self.assertIn('speakers', form.formsets)
        self.assertNotIn('related_links', form.formsets)
开发者ID:Fluxflashor,项目名称:wagtail,代码行数:12,代码来源:test_edit_handlers.py


示例8: setUp

    def setUp(self):
        model = PageChooserModel
        self.chosen_page = Page.objects.get(pk=2)
        test_instance = model.objects.create(page=self.chosen_page)
        self.dotted_model = model._meta.app_label + '.' + model._meta.model_name

        self.page_chooser_panel_class = PageChooserPanel('page', model)

        form_class = get_form_for_model(model, widgets=self.page_chooser_panel_class.widget_overrides())
        form = form_class(instance=test_instance)
        form.errors['page'] = form.error_class(['errors'])

        self.page_chooser_panel = self.page_chooser_panel_class(instance=test_instance,
                                                                form=form)
开发者ID:akrawchyk,项目名称:wagtail,代码行数:14,代码来源:test_edit_handlers.py


示例9: get_form_class

    def get_form_class(cls, model):

        # def clean(form):
        #     if form.__class__.__name__ == 'ProgramSectionPageForm':
        #         form.data['title'] = 'TEST - TITLE'
        #         form.data['slug'] = "{0}-{1}".format(form.data['start_time'], form.data['end_time'])
        #     return form.clean()

        if cls._form_class is None:
            cls._form_class = get_form_for_model(
                model,
                formsets=cls.required_formsets(), widgets=cls.widget_overrides())
            # cls._form_class.clean = clean
        return cls._form_class
开发者ID:taroved,项目名称:fk,代码行数:14,代码来源:edit_handlers.py


示例10: test_get_form_for_model_with_excluded_fields

    def test_get_form_for_model_with_excluded_fields(self):
        EventPageForm = get_form_for_model(EventPage, exclude=['title'], exclude_formsets=['related_links'])
        form = EventPageForm()

        # form should contain date_from but not title
        self.assertEqual(type(form.fields['date_from']), forms.DateField)
        self.assertEqual(type(form.fields['date_from'].widget), AdminDateInput)
        self.assertNotIn('title', form.fields)

        # 'path' should still be excluded even though it isn't explicitly in the exclude list
        self.assertNotIn('path', form.fields)

        # formsets should include speakers but not related_links
        self.assertIn('speakers', form.formsets)
        self.assertNotIn('related_links', form.formsets)
开发者ID:Fluxflashor,项目名称:wagtail,代码行数:15,代码来源:test_edit_handlers.py


示例11: test_get_form_for_model

    def test_get_form_for_model(self):
        EventPageForm = get_form_for_model(EventPage)
        form = EventPageForm()

        # 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:Fluxflashor,项目名称:wagtail,代码行数:17,代码来源:test_edit_handlers.py


示例12: test_get_form_for_model_with_excluded_fields

    def test_get_form_for_model_with_excluded_fields(self):
        EventPageForm = get_form_for_model(
            EventPage, form_class=WagtailAdminPageForm,
            exclude=['title'], exclude_formsets=['related_links'])
        form = EventPageForm()

        # form should contain date_from but not title
        self.assertEqual(type(form.fields['date_from']), forms.DateField)
        self.assertEqual(type(form.fields['date_from'].widget), AdminDateInput)
        self.assertNotIn('title', form.fields)

        # 'path' is not excluded any more, as the excluded fields were overridden
        self.assertIn('path', form.fields)

        # formsets should include speakers but not related_links
        self.assertIn('speakers', form.formsets)
        self.assertNotIn('related_links', form.formsets)
开发者ID:DjangoBD,项目名称:wagtail,代码行数:17,代码来源:test_edit_handlers.py


示例13: test_get_form_for_model_with_widget_overides_by_instance

    def test_get_form_for_model_with_widget_overides_by_instance(self):
        EventPageForm = get_form_for_model(EventPage, widgets={'date_from': forms.PasswordInput()})
        form = EventPageForm()

        self.assertEqual(type(form.fields['date_from']), forms.DateField)
        self.assertEqual(type(form.fields['date_from'].widget), forms.PasswordInput)
开发者ID:Fluxflashor,项目名称:wagtail,代码行数:6,代码来源:test_edit_handlers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap