Add and fix utility functions for working with apps and models.

Review Request #10551 — Created May 13, 2019 and submitted — Latest diff uploaded

Information

Django Evolution
master
6c08cdc...

Reviewers

This introduces and reworks some utility functions for retrieving or
parsing information on apps. get_app_label() and get_app_name() now
retrieve their informatoin from the AppConfig on Django 1.7+, and the
AppConfig can now be retrieved through get_app_config_for_app(). The
old legacy version of the label can be returned using
get_legacy_app_label().

At the moment, this will return some incompatible information for apps
when using a new-style app label on modern versions of Django, but this
wasn't expected to work yet anyway.

Model fetching also has fixes on Django 1.7+. It no longer assumes
anything about the provided app module's label, and instead loops
through apps looking for one that owns the provided module.

These will be needed for the app label support coming in the next
change.

Unit tests pass on Django 1.6. This change temporarily breaks them on
newer versions.