Django

Code

Ticket #3221 (new)

Opened 1 year ago

Last modified 8 months ago

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

Reported by: imbaczek@gmail.com Assigned to: oggie_rob
Component: Core framework Version:
Keywords: Cc:
Triage Stage: Accepted Has patch: 1
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

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

3221_import_error.diff (0.7 kB) - added by oggie_rob on 09/14/07 16:58:13.
Catch ImpotError? & raise ValidationError? to clarify location/problem with import

Change History

01/30/07 02:58:20 changed by Simon G. <dev@simon.net.nz>

  • has_patch set to 1.
  • summary changed from unhelpful error message when include() set incorrectly to [patch] unhelpful error message when include() set incorrectly.
  • stage changed from Unreviewed to Accepted.

09/14/07 16:56:50 changed by oggie_rob

  • owner changed from nobody to oggie_rob.

09/14/07 16:58:13 changed by oggie_rob

  • attachment 3221_import_error.diff added.

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

09/14/07 17:02:00 changed by oggie_rob

Fixed by re-throwing error with more explicit message.


Add/Change #3221 ([patch] unhelpful error message when include() set incorrectly)




Change Properties
Action