﻿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
21770	Management commands autocomplete broken	Akis Kesoglou	Aymeric Augustin	"Tabbing for command autocompletion in manage.py raises the following error:

{{{
$ ./manage.py sql<Tab>

Traceback (most recent call last):
  File ""./manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/<virtualenv>/src/django/django/core/management/__init__.py"", line 426, in execute_from_command_line
    utility.execute()
  File ""/<virtualenv>/src/django/django/core/management/__init__.py"", line 379, in execute
    self.autocomplete()
  File ""/<virtualenv>/src/django/django/core/management/__init__.py"", line 326, in autocomplete
    subcommands = list(get_commands()) + ['help']
  File ""/<virtualenv>/bin/../lib/python3.3/functools.py"", line 251, in wrapper
    result = user_function(*args, **kwds)
  File ""/<virtualenv>/src/django/django/core/management/__init__.py"", line 118, in get_commands
    app_configs = apps.get_app_configs()
  File ""/<virtualenv>/src/django/django/apps/registry.py"", line 121, in get_app_configs
    self.check_ready()
  File ""/<virtualenv>/src/django/django/apps/registry.py"", line 115, in check_ready
    raise RuntimeError(""App registry isn't ready yet."")
RuntimeError: App registry isn't ready yet.
}}}

Bringing the issue up in #django-dev, mjtamlyn suggested moving the try/catch with django.setup() block to the beginning of ManagementUtility.execute() method, which fixed the issue. However, the change broke the test suite, specifically many tests from test_admin_scripts.

I'm not at all familiar with that (huge) part of the test suite, so i'm not sure how to go about it, even though i'm willing to help.

Python 3.3, Django@9918c11114ac3
"	Bug	closed	Core (Management commands)	dev	Release blocker	fixed	app-loading		Accepted	0	0	0	0	0	0
