Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning

NOTE: If you're writing new Django apps, do not import models inside the __init__.py (root package) of the application.

The errors caused by this premature model importing will look similiar to this one:

Code Block
languagepy
Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 331, in run
    testMethod()
  File "/home/jenkins/edx-venv/local/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/jenkins/edx-venv/local/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/jenkins/edx-venv/local/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/jenkins/workspace/edx-platform-test-subset/common/lib/xmodule/xmodule/video_module/__init__.py", line 8, in <module>
    from .transcripts_utils import *
  File "/home/jenkins/workspace/edx-platform-test-subset/common/lib/xmodule/xmodule/video_module/transcripts_utils.py", line 18, in <module>
    from .bumper_utils import get_bumper_settings
  File "/home/jenkins/workspace/edx-platform-test-subset/common/lib/xmodule/xmodule/video_module/bumper_utils.py", line 16, in <module>
    import edxval.api as edxval_api
  File "/home/jenkins/edx-venv/local/lib/python2.7/site-packages/edxval/api.py", line 13, in <module>
    from edxval.models import Video, EncodedVideo, CourseVideo, Profile
  File "/home/jenkins/edx-venv/local/lib/python2.7/site-packages/edxval/models.py", line 48, in <module>
    class Profile(models.Model):
  File "/home/jenkins/edx-venv/local/lib/python2.7/site-packages/django/db/models/base.py", line 94, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/home/jenkins/edx-venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
    self.check_apps_ready()
  File "/home/jenkins/edx-venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
AppRegistryNotReady: Apps aren't loaded yet.

After modifying 5+ external Python modules, changing their requirements entries, and changing around the startup.py files, I was able to run the following command to completion:

...

The branch I created for this work is here:

https://github.com/edx/edx-platform/tree/jeskew/django_1_9_compat

And the PR I used to run tests is here:

https://github.com/edx/edx-platform/pull/12770

I also created branches/forks in other repos. To find all those changes, review the base.txt/github.txt files from the requirements files on the branch above.