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