Fixed #21478 -- Corrected docs for when Field.db_type() is called.
Switched setup.py to setuptools.
Introduced as_bytes for SafeMIMEText (and other SafeMIME-classes).

This is to provide a consistent interface (namely bytes) for the smtp
backend which after all sends bytes over the wire; encoding with as_string
yields different results since mails as unicode are not really specified.

as_string stays for backwardscompatibilty mostly and some debug outputs.
But keep in mind that the output doesn't match as_bytes!
Skipped inclusion of scripts (pip will take care of that).
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.