From e9c6d0422422d7ea5ff3be8992ca73b5ba73bd0c Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Thu, 5 Dec 2013 14:19:46 +0000 Subject: [PATCH] Better error reporting when from_app_cache fails --- django/db/migrations/state.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index f5019f65ee..0dd8d85e10 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -99,11 +99,25 @@ class ModelState(object): for field in model._meta.local_fields: name, path, args, kwargs = field.deconstruct() field_class = import_by_path(path) - fields.append((name, field_class(*args, **kwargs))) + try: + fields.append((name, field_class(*args, **kwargs))) + except TypeError as e: + raise TypeError("Couldn't reconstruct field %s on %s: %s" % ( + name, + model._meta.object_name, + e, + )) for field in model._meta.local_many_to_many: name, path, args, kwargs = field.deconstruct() field_class = import_by_path(path) - fields.append((name, field_class(*args, **kwargs))) + try: + fields.append((name, field_class(*args, **kwargs))) + except TypeError as e: + raise TypeError("Couldn't reconstruct m2m field %s on %s: %s" % ( + name, + model._meta.object_name, + e, + )) # Extract the options options = {} for name in DEFAULT_NAMES: