From 2e3c7d882015375c130c21884d83cb9fb7759d94 Mon Sep 17 00:00:00 2001 From: Loic Bistuer Date: Sat, 7 Dec 2013 23:01:17 +0700 Subject: [PATCH] Trigger AttributeError in ValidationError.message_dict when error_dict 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. --- django/core/exceptions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/django/core/exceptions.py b/django/core/exceptions.py index 78f6d07cf3..cf4aea0f36 100644 --- a/django/core/exceptions.py +++ b/django/core/exceptions.py @@ -123,6 +123,10 @@ class ValidationError(Exception): @property def message_dict(self): + # Trigger an AttributeError if this ValidationError + # doesn't have an error_dict. + getattr(self, 'error_dict') + return dict(self) @property