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


Python formsets.ORDERING_FIELD_NAME属性代码示例

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


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

示例1: ordering_field

# 需要导入模块: from django.forms import formsets [as 别名]
# 或者: from django.forms.formsets import ORDERING_FIELD_NAME [as 别名]
def ordering_field(self):
        from django.forms.formsets import ORDERING_FIELD_NAME
        return AdminField(self.form, ORDERING_FIELD_NAME, False) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:5,代码来源:helpers.py

示例2: on_form_bound

# 需要导入模块: from django.forms import formsets [as 别名]
# 或者: from django.forms.formsets import ORDERING_FIELD_NAME [as 别名]
def on_form_bound(self):
        self.formset = self.form.formsets[self.relation_name]

        self.children = []
        for subform in self.formset.forms:
            # override the DELETE field to have a hidden input
            subform.fields[DELETION_FIELD_NAME].widget = forms.HiddenInput()

            # ditto for the ORDER field, if present
            if self.formset.can_order:
                subform.fields[ORDERING_FIELD_NAME].widget = forms.HiddenInput()

            child_edit_handler = self.get_child_edit_handler()
            self.children.append(child_edit_handler.bind_to(
                instance=subform.instance, request=self.request, form=subform))

        # if this formset is valid, it may have been re-ordered; respect that
        # in case the parent form errored and we need to re-render
        if self.formset.can_order and self.formset.is_valid():
            self.children.sort(
                key=lambda child: child.form.cleaned_data[ORDERING_FIELD_NAME] or 1)

        empty_form = self.formset.empty_form
        empty_form.fields[DELETION_FIELD_NAME].widget = forms.HiddenInput()
        if self.formset.can_order:
            empty_form.fields[ORDERING_FIELD_NAME].widget = forms.HiddenInput()

        self.empty_child = self.get_child_edit_handler()
        self.empty_child = self.empty_child.bind_to(
            instance=empty_form.instance, request=self.request, form=empty_form) 
开发者ID:wagtail,项目名称:wagtail,代码行数:32,代码来源:edit_handlers.py


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