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


Python formsets.all_valid方法代码示例

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


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

示例1: test_valid

# 需要导入模块: from django.forms import formsets [as 别名]
# 或者: from django.forms.formsets import all_valid [as 别名]
def test_valid(self):
        data = {
            'choices-TOTAL_FORMS': '2',
            'choices-INITIAL_FORMS': '0',
            'choices-MIN_NUM_FORMS': '0',
            'choices-0-choice': 'Zero',
            'choices-0-votes': '0',
            'choices-1-choice': 'One',
            'choices-1-votes': '1',
        }
        ChoiceFormSet = formset_factory(Choice)
        formset1 = ChoiceFormSet(data, auto_id=False, prefix='choices')
        formset2 = ChoiceFormSet(data, auto_id=False, prefix='choices')
        self.assertIs(all_valid((formset1, formset2)), True)
        expected_errors = [{}, {}]
        self.assertEqual(formset1._errors, expected_errors)
        self.assertEqual(formset2._errors, expected_errors) 
开发者ID:nesdis,项目名称:djongo,代码行数:19,代码来源:test_formsets.py

示例2: test_invalid

# 需要导入模块: from django.forms import formsets [as 别名]
# 或者: from django.forms.formsets import all_valid [as 别名]
def test_invalid(self):
        """all_valid() validates all forms, even when some are invalid."""
        data = {
            'choices-TOTAL_FORMS': '2',
            'choices-INITIAL_FORMS': '0',
            'choices-MIN_NUM_FORMS': '0',
            'choices-0-choice': 'Zero',
            'choices-0-votes': '',
            'choices-1-choice': 'One',
            'choices-1-votes': '',
        }
        ChoiceFormSet = formset_factory(Choice)
        formset1 = ChoiceFormSet(data, auto_id=False, prefix='choices')
        formset2 = ChoiceFormSet(data, auto_id=False, prefix='choices')
        self.assertIs(all_valid((formset1, formset2)), False)
        expected_errors = [{'votes': ['This field is required.']}, {'votes': ['This field is required.']}]
        self.assertEqual(formset1._errors, expected_errors)
        self.assertEqual(formset2._errors, expected_errors) 
开发者ID:nesdis,项目名称:djongo,代码行数:20,代码来源:test_formsets.py

示例3: valid_forms

# 需要导入模块: from django.forms import formsets [as 别名]
# 或者: from django.forms.formsets import all_valid [as 别名]
def valid_forms(self, result):
        return all_valid(self.formsets) and result 
开发者ID:stormsha,项目名称:StormOnline,代码行数:4,代码来源:inline.py


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