Code

Opened 6 years ago

Closed 6 years ago

#7979 closed (duplicate)

django doesn't give a traceback for errors resulting from importing the root URLconf

Reported by: trevor Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords:
Cc: rokclimb15@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If the root URLconf raises an error causing django to crash, instead of displaying that traceback, django shows a traceback leading up to the __import__ statement which imports the root URLconf (and then raises ImproperlyConfigured).

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by rokclimb15@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

This is a fairly minor but annoying issue. To reproduce, duplicate an admin.site.register call in admin.py. The AlreadyRegistered exception is masked by the ImproperlyConfigured. In order to see the original traceback, you have to drop into the django project shell and import the offending admin module.

I think the traceback should be made available on the exception or no exceptions should be caught and should simply be allowed to bubble up as-is.

comment:2 Changed 6 years ago by anonymous

  • Cc rokclimb15@… added

comment:3 Changed 6 years ago by trevor

It is even more annoying when importing the module itself doesn't give a traceback.

For example, if you have your settings module in a subpackage (for example "project") and have modified manage.py accordingly (to import project.settings instead of settings), when you run ./manage.py shell, import settings will work, even if the module subpackage isn't explicitly added to your python path. If you are running your application sans manage.py, for example with apache, and do not add the project subpackage to your python path, import settings will no longer work. If a module which is imported by your root URLconf calls import settings, you will get the ImproperlyConfigured error, and trying to debug that via ./manage.py shell will not work. Had the original traceback been available in the first place, the error would have been obvious.

comment:4 Changed 6 years ago by jacob

  • Triage Stage changed from Unreviewed to Design decision needed

While this is annoying, I'm not sure if there's anything we can do about it.

comment:5 Changed 6 years ago by jarrow

  • Resolution set to duplicate
  • Status changed from new to closed

This is a duplicate of #7524 that also has a patch.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.