Browse files

Trigger AttributeError in ValidationError.message_dict when error_dic…

…t is missing.

The goal of this change is twofold; firstly, matching the behavior of Django 1.6
and secondly, an AttributeError is more informative than an obscure ValueError
about mismatching sequence lengths.

Refs #20867.
  • Loading branch information...
loic committed Dec 7, 2013
1 parent 65faa84 commit 2e3c7d882015375c130c21884d83cb9fb7759d94
Showing with 4 additions and 0 deletions.
  1. +4 −0 django/core/
@@ -123,6 +123,10 @@ def __init__(self, message, code=None, params=None):
def message_dict(self):
+ # Trigger an AttributeError if this ValidationError
+ # doesn't have an error_dict.
+ getattr(self, 'error_dict')
return dict(self)

0 comments on commit 2e3c7d8

Please sign in to comment.