Opened 18 years ago

Closed 15 years ago

#3221 closed enhancement (fixed)

[patch] unhelpful error message when include() set incorrectly

Reported by: imbaczek@… Owned by: oggie_rob
Component: Core (Other) Version:
Severity: minor Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

instead of 'module' has no attribute 'urlpatterns', a more useful error message would be nice to have, as I just wasted 30 mins of time just to notice I forgot to append .urls in an include() in urlconf.

I've patched my django.core.urlresolvers with this:

Index: urlresolvers.py
===================================================================
--- urlresolvers.py     (wersja 4270)
+++ urlresolvers.py     (kopia robocza)
@@ -157,6 +157,8 @@
         match = self.regex.search(path)
         if match:
             new_path = path[match.end():]
+            if not hasattr(self.urlconf_module, 'urlpatterns'):
+                raise AttributeError('urlpatterns in module %s not found, is the parent urlconf correct?'%self.urlconf_module.__name__)
             for pattern in self.urlconf_module.urlpatterns:
                 try:
                     sub_match = pattern.resolve(new_path)

Attachments (1)

3221_import_error.diff (725 bytes ) - added by oggie_rob 17 years ago.
Catch ImpotError & raise ValidationError to clarify location/problem with import

Download all attachments as: .zip

Change History (5)

comment:1 by Simon G. <dev@…>, 18 years ago

Has patch: set
Summary: unhelpful error message when include() set incorrectly[patch] unhelpful error message when include() set incorrectly
Triage Stage: UnreviewedAccepted

comment:2 by oggie_rob, 17 years ago

Owner: changed from nobody to oggie_rob

by oggie_rob, 17 years ago

Attachment: 3221_import_error.diff added

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

comment:3 by oggie_rob, 17 years ago

Fixed by re-throwing error with more explicit message.

comment:4 by Dennis Kaarsemaker, 15 years ago

Resolution: fixed
Status: newclosed

A slightly different more useful error message has found its way into the trunk already.

Note: See TracTickets for help on using tickets.
Back to Top