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

Review Request #10551 — Created May 13, 2019 and updated

Django Evolution

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

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

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

Description From Last Updated

Seems like this could use your new get_app_config_for_app helper.

Review request changed

Change Summary:

Forgot to stage a fix for commit.




Revision 2 (+59 -9)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
  2. django_evolution/compat/ (Diff revision 2)

    Seems like this could use your new get_app_config_for_app helper.

    1. Ideally... There's currently a circular import issue, and it's something I want to figure out once I get past all the heavy lifting. In this case, the moduel that defines that method (utils/ imports compat/, which imports compat/ I could have an import within the function body, but the logic is standard and safe enough where I don't want to deal with that here.

      Currently, I'm saying that things in compat can't depend on utils.