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


Python utils.ErrorDict方法代码示例

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


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

示例1: full_clean

# 需要导入模块: from django.forms import utils [as 别名]
# 或者: from django.forms.utils import ErrorDict [as 别名]
def full_clean(self):
        """
        Cleans all of self.data and populates self._errors and
        self.cleaned_data.
        """
        self._errors = ErrorDict()
        if not self.is_bound:  # Stop further processing.
            return
        self.cleaned_data = {}
        # If the form is permitted to be empty, and none of the form data has
        # changed from the initial data, short circuit any validation.
        if self.empty_permitted and not self.has_changed():
            return

        self._clean_fields()
        self._clean_form()
        self._post_clean() 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:19,代码来源:forms.py

示例2: full_clean

# 需要导入模块: from django.forms import utils [as 别名]
# 或者: from django.forms.utils import ErrorDict [as 别名]
def full_clean(self):
        self._errors = ErrorDict()
        
        if not self.is_bound:  # Stop further processing.
            return
        
        self.cleaned_data = {}

        # If the form is permitted to be empty, and none of the form data has
        # changed from the initial data, short circuit any validation.
        if self.empty_permitted and not self.has_changed():
            return
        
        # Don't run _post_clean() as this will run StockItem.clean()
        self._clean_fields()
        self._clean_form() 
开发者ID:inventree,项目名称:InvenTree,代码行数:18,代码来源:forms.py

示例3: test_error_dict_copy

# 需要导入模块: from django.forms import utils [as 别名]
# 或者: from django.forms.utils import ErrorDict [as 别名]
def test_error_dict_copy(self):
        e = ErrorDict()
        e['__all__'] = ErrorList([
            ValidationError(
                message='message %(i)s',
                params={'i': 1},
            ),
            ValidationError(
                message='message %(i)s',
                params={'i': 2},
            ),
        ])

        e_copy = copy.copy(e)
        self.assertEqual(e, e_copy)
        self.assertEqual(e.as_data(), e_copy.as_data())

        e_deepcopy = copy.deepcopy(e)
        self.assertEqual(e, e_deepcopy)
        self.assertEqual(e.as_data(), e_copy.as_data()) 
开发者ID:nesdis,项目名称:djongo,代码行数:22,代码来源:test_utils.py

示例4: test_error_class

# 需要导入模块: from django.forms import utils [as 别名]
# 或者: from django.forms.utils import ErrorDict [as 别名]
def test_error_class(self):
        '''
        Test the type of Formset and Form error attributes
        '''
        Formset = modelformset_factory(User, fields="__all__")
        data = {
            'form-TOTAL_FORMS': '2',
            'form-INITIAL_FORMS': '0',
            'form-MAX_NUM_FORMS': '0',
            'form-0-id': '',
            'form-0-username': 'apollo13',
            'form-0-serial': '1',
            'form-1-id': '',
            'form-1-username': 'apollo13',
            'form-1-serial': '2',
        }
        formset = Formset(data)
        # check if the returned error classes are correct
        # note: formset.errors returns a list as documented
        self.assertIsInstance(formset.errors, list)
        self.assertIsInstance(formset.non_form_errors(), ErrorList)
        for form in formset.forms:
            self.assertIsInstance(form.errors, ErrorDict)
            self.assertIsInstance(form.non_field_errors(), ErrorList) 
开发者ID:nesdis,项目名称:djongo,代码行数:26,代码来源:tests.py

示例5: errors

# 需要导入模块: from django.forms import utils [as 别名]
# 或者: from django.forms.utils import ErrorDict [as 别名]
def errors(self):
        "Returns an ErrorDict for the data provided for the form"
        if self._errors is None:
            self.full_clean()
        return self._errors 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:forms.py

示例6: full_clean

# 需要导入模块: from django.forms import utils [as 别名]
# 或者: from django.forms.utils import ErrorDict [as 别名]
def full_clean(self):
        if self.data.get(self.prefix + '-remove') != 'on':
            super().full_clean()
        else:
            self._errors = ErrorDict()
            self.cleaned_data = {'remove': True} 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:8,代码来源:forms.py

示例7: test_full_clean_remove

# 需要导入模块: from django.forms import utils [as 别名]
# 或者: from django.forms.utils import ErrorDict [as 别名]
def test_full_clean_remove(self):
        data = {
            'contacts-name': 'John',
            'contacts-email': 'john@beatles.uk',
            'contacts-remove': 'on'
        }
        form = forms.ContactsForm(data=data, prefix='contacts')
        form.full_clean()
        assert form.cleaned_data == {'remove': True}
        assert isinstance(form._errors, ErrorDict) 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:12,代码来源:test_forms.py

示例8: test_error_dict_html_safe

# 需要导入模块: from django.forms import utils [as 别名]
# 或者: from django.forms.utils import ErrorDict [as 别名]
def test_error_dict_html_safe(self):
        e = ErrorDict()
        e['username'] = 'Invalid username.'
        self.assertTrue(hasattr(ErrorDict, '__html__'))
        self.assertEqual(str(e), e.__html__()) 
开发者ID:nesdis,项目名称:djongo,代码行数:7,代码来源:test_utils.py


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