Avoided leaking state on exceptions in populate_models().
Populated the app registry earlier at startup.

Refs #1796, #21676.
Added AppConfig.setup() to run setup code.
Updated advice on connecting signals at startup.
Populated Apps instances immediately by default.
Stopped populating the app registry as a side effect.

Since it triggers imports, it shouldn't be done lightly.

This commit adds a public API for doing it explicitly, django.setup(),
and does it automatically when using manage.py and wsgi.py.