You'll get an exception mentioning that apps aren't ready yet. If you call
django.setup() in a manual script you'll get a nice exception by which it
is possible to see that your logging config is invalid.
The problem lies somewhere in the management command setup, or in the way
get_app_configs() reports errors.
Stacktrace:
{{{
(tehku2_env)securejava@debian:~/projects/testapp$ python manage.py
runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/core/management/__init__.py", line 351, in
execute_from_command_line
utility.execute()
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/core/management/__init__.py", line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/core/management/__init__.py", line 177, in fetch_command
commands = get_commands()
File "/home/securejava/projects/tehku2_env/lib/python3.4/functools.py",
line 434, in wrapper
result = user_function(*args, **kwds)
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/core/management/__init__.py", line 72, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
}}}
Interestingly if you run instead manage.py --version, the exception isn't
swallowed.
--
Ticket URL: <https://code.djangoproject.com/ticket/25555>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Comment:
This is due to `runserver` being special-cased from
cc14d51ee8325c82665cb98af4dfe49aab565d52 / #24704 (sorry Aymeric!)
--
Ticket URL: <https://code.djangoproject.com/ticket/25555#comment:1>
Comment (by aaugustin):
This could be a duplicate of #25510. Anssi, can you test if
https://github.com/django/django/pull/5402 improves the situation?
--
Ticket URL: <https://code.djangoproject.com/ticket/25555#comment:2>
Comment (by akaariai):
Yes, that one fixes the issue. Instead of getting apps not ready
exception, I can see the original exception on command line. If I fix the
error in the settings, the project is correctly reloaded.
If I start the runserver with an exception caused by a mistake in
models.py of some installed app, then I get the following exception:
{{{
(tehku2_env)securejava@debian:~/projects/tehku2$ python manage.py
runserver
Traceback (most recent call last):
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/core/management/__init__.py", line 317, in execute
autoreload.check_errors(django.setup)()
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File
"/home/securejava/projects/tehku2_env/lib/python3.4/importlib/__init__.py",
line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in
_call_with_frames_removed
File "/home/securejava/projects/tehku2/tehku/models.py", line 114, in
<module>
raise Exception("hara")
Exception: hara
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/core/management/__init__.py", line 351, in
execute_from_command_line
utility.execute()
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/core/management/__init__.py", line 321, in execute
apps.populate([])
File "/home/securejava/projects/tehku2_env/lib/python3.4/site-
packages/django/apps/registry.py", line 78, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
}}}
I guess we want to avoid that.
--
Ticket URL: <https://code.djangoproject.com/ticket/25555#comment:3>
* status: new => closed
* resolution: => duplicate
Comment:
I left the same comment about avoiding `RuntimeError: populate() isn't
reentrant` on the pull request.
--
Ticket URL: <https://code.djangoproject.com/ticket/25555#comment:4>
Comment (by aaugustin):
I'm closing this ticket since it appears identical to #25510. FYI I
updated the PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/25555#comment:5>