#13352 closed (fixed)
ValidationError should be able to repr itself
Reported by: | elpaso66 | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Actual behaviour:
In [1]: from django.core.exceptions import * In [2]: ValidationError('Test') Out[2]: ValidationError() In [3]: ValidationError(['Test1', 'Test2']) Out[3]: ValidationError()
Expected behaviour:
In [1]: from django.core.exceptions import * In [2]: ValidationError('Test') Out[2]: ValidationError([u'Test']) In [3]: ValidationError(['Test1', 'Test2']) Out[3]: ValidationError([u'Test1', u'Test2'])
Patch:
Index: django/core/exceptions.py =================================================================== --- django/core/exceptions.py (revision 12889) +++ django/core/exceptions.py (working copy) @@ -64,6 +64,11 @@ return repr(self.message_dict) return repr(self.messages) + def __repr__(self): + if hasattr(self, 'message_dict'): + return 'ValidationError(%s)' % repr(self.message_dict) + return 'ValidationError(%s)' % repr(self.messages) + def update_error_dict(self, error_dict): if hasattr(self, 'message_dict'): if error_dict:
Change History (4)
comment:1 by , 15 years ago
milestone: | → 1.2 |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
Component: | Uncategorized → Core framework |
---|
comment:3 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
(In [12976]) Fixed #13352 -- Added repr method for Validation Error. Thanks to elpaso66 for the report.