Opened 8 years ago

Closed 8 years ago

#12300 closed (duplicate)

Catching exceptions and printing messages without file name and line number

Reported by: Piotr Czachur Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords: ImportError
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:



Lately I had a typo in app name in INSTALLED_APPS. What I get from django when trying to run shell, test etc. was:

$ python shell 
Error: No module named name_with_typo

Like you see this message just suggest, that importing were wrong, because module is not accessible.
If my module name was really "name_with_typo" I would find it very fast, but my name was "model", so browsing sources to find the reason was a bit exhausting.
I start debugger and find that exception was catched here:

# django/core/management/
        # Switch to English, because creates database content
        # like permissions, and those shouldn't contain any translations.
        # But only do this if we can assume we have a working settings file,
        # because django.utils.translation requires settings.
        if self.can_import_settings:
                from django.utils import translation
            except ImportError, e:
                # If settings should be available, but aren't,
                # raise the error and quit.
                sys.stderr.write('Error: %s\n' % e)))

Exception was raised during


As you see it's not much intuitive...

Why not to make error message more verbose?
It would save our time.

Such "error handling" is used in many places of Django.


Change History (1)

comment:1 Changed 8 years ago by Allen Riddell

Resolution: duplicate
Status: newclosed

There's a patch for this problem in 11667

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