﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10706	Incorrect error from manage.py sql when app fails to load	Glenn Maynard	nobody	"{{{
./manage.py sql stomp
Error: App with label stomp could not be found. Are you sure your INSTALLED_APPS setting is correct?
}}}

This is an incorrect error when the app is found but fails to import.  The actual error is never displayed, which is hard to diagnose.  If I add some diagnostics in django/db/models/loading.py load_app to print the exception, the problem becomes obvious:

{{{
./manage.py sqlall stomp
cannot import name TestModel
Error: App with label stomp could not be found. Are you sure your INSTALLED_APPS setting is correct?
}}}

It should probably just pass the exception up and show a trace.  I've attached a patch to do this, but it causes errors when running some tests:

{{{
Error while importing humanize:  File ""./runtests.py"", line 134, in django_tests
    mod = load_app(model_label)
  File ""/home/glenn/django/django/db/models/loading.py"", line 74, in load_app
    models = import_module('.models', app_name)
  File ""/home/glenn/django/django/utils/importlib.py"", line 35, in import_module
    __import__(name)
ImportError: No module named models
}}}

for humanize, syndication, sitemaps, databrowse, admindocs and localflavor.  Spying on runtests.py django_tests, these seem to be failing silently anyway; this is just making the ""Error while importing"" exception handler actually get called, where before they were silent.  I'm not sure if there's another bug in there that this is exposing.

(Watch out: there's both eg. regressiontests.humanize and django.contrib.humanize for a few of those tests, and usually one of them works and the other doesn't.)
"	Bug	closed	Core (Management commands)	dev	Normal	fixed		xiong.chiamiov@…	Accepted	1	0	0	1	0	0
