本文整理汇总了Python中django.forms.Form.errors[u'SimpleError']方法的典型用法代码示例。如果您正苦于以下问题:Python Form.errors[u'SimpleError']方法的具体用法?Python Form.errors[u'SimpleError']怎么用?Python Form.errors[u'SimpleError']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.Form
的用法示例。
在下文中一共展示了Form.errors[u'SimpleError']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testJsonResponseWithStatus400ReturnErrorsWhenSettingsSpecifyErrorReporting
# 需要导入模块: from django.forms import Form [as 别名]
# 或者: from django.forms.Form import errors[u'SimpleError'] [as 别名]
def testJsonResponseWithStatus400ReturnErrorsWhenSettingsSpecifyErrorReporting(self):
settings.DYNAMICRESPONSE_JSON_FORM_ERRORS = True
simple_form = Form()
simple_form.is_valid = Mock(return_value=False)
simple_form.errors[u'SimpleError'] = u'This was a very simple error, shame on you'
simple_form.errors[u'Error2'] = u'This was a bit more serious'
should_equal = simplejson.dumps({'field_errors': simple_form.errors}, indent=0)
dynRes = DynamicResponse({}, extra={ 'form': simple_form }, status=CR_INVALID_DATA)
serialized_result = dynRes.serialize()
self.assertTrue(isinstance(serialized_result, JsonResponse))
self.assertEqual(should_equal, serialized_result.content, 'Correct error message is not returned from JsonResponse')