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

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

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.

Description From Last Updated

Seems like this could use your new get_app_config_for_app helper.

daviddavid
chipx86
david
  1. 
      
  2. django_evolution/compat/models.py (Diff revision 2)
     
     
     
    Show all issues

    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/apps.py) imports compat/apps.py, which imports compat/models.py. 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.

  3. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (0e4e3e0)