Refactored the migration signals to use app configs.

De-aliased pre/post_syncdb to pre/post_migrate to increase
backwards-compatibility.
Cleared get_models cache when swapping User model.

Thanks Florian for isolating the shortest way to reproduce this issue:

./runtests.py \
    django.contrib.auth.tests.test_context_processors.AuthContextProcessorTests.test_perms_attrs \
    django.contrib.auth.tests.test_auth_backends.ChangedBackendSettingsTest.test_changed_backend_settings \
    django.contrib.auth.tests.test_auth_backends.CustomUserModelBackendAuthenticateTest.test_authenticate \
    django.contrib.auth.tests.test_basic.BasicTestCase.test_createsuperuser_management_command
Replaced Options.object_name.lower() by Options.model_name.

Thanks Simon for the suggestion.

Also removed inappropriate lowercasing of app labels in migrations.
Unlike model names, they are case sensitive.
Cleared global templatetags module cache.

TOOOOO MUCH GLOBAL STATE (you didn't see that).
Added AppConfig.get_models().
Fixed a typo.

Thanks Simon.
Added Apps.clear_cache().

This avoid leaking implementation details to tests that swap models.
Removed obsolete docstring.
Removed unused import.
Fixed stupid error in 21f22f95.
Used Apps.clear_cache() in tests that alter the app registry.
Changed sql_* to use an app config instead of a models module.
Changed get_migratable_models to use an app config.
Changed get_validation_errors to use an app config.
Deprecated the app argument of apps.get_models.

Use app_config.get_models() instead.
Stopped calling get_models() for a side effect.
Converted links to HTTPS and linked to stable docs.