Code

Ticket #3221: 3221_import_error.diff

File 3221_import_error.diff, 725 bytes (added by oggie_rob, 7 years ago)

Catch ImpotError & raise ValidationError to clarify location/problem with import

Line 
1Index: django/core/urlresolvers.py
2===================================================================
3--- django/core/urlresolvers.py (revision 6194)
4+++ django/core/urlresolvers.py (working copy)
5@@ -233,6 +233,8 @@
6                     sub_match = pattern.resolve(new_path)
7                 except Resolver404, e:
8                     tried.extend([(pattern.regex.pattern + '   ' + t) for t in e.args[0]['tried']])
9+                except ImportError, e:
10+                    raise AttributeError('included urlpattern "%s" not found' % pattern.urlconf_name)
11                 else:
12                     if sub_match:
13                         sub_match_dict = dict([(smart_str(k), v) for k, v in match.groupdict().items()])