Django 1.8 to 1.9 upgrade: django.core.exceptions.

2019-03-16 22:35发布

问题:

I have a project currently working on Django 1.8. Since 1.9 just released, I thought I would update via pip install django==1.9. However, when running python manage.py test -v 3, I get this error:

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/core/management/__init__.py", line 324, in execute
    django.setup()
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/reversion/__init__.py", line 11, in <module>
    from reversion.revisions import default_revision_manager, revision_context_manager, VersionAdapter
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/reversion/revisions.py", line 18, in <module>
    from django.contrib.contenttypes.models import ContentType
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 159, in <module>
    class ContentType(models.Model):
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/db/models/base.py", line 94, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
    self.check_apps_ready()
  File "/home/user/Envs/intranet/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

I am aware that INSTALLED_APPS changed from a tuple to a list.

Anything else that I might have missed?

回答1:

Try to upgrade django-reversion, today was released 1.10 version with:

Django 1.9 compatibility (@etianen).

message from discussion groups https://groups.google.com/forum/#!topic/django-reversion/3AQipnbKaUI

The latest release of django-reversion (1.10.0) is now available on GitHub and PyPi. This release adds compatibility with Django 1.9.

Important: This release contains breaking changes. Please review the release notes on GitHub before installing.

These breaking changes were unfortunately required in order to support Django 1.9. Happily, all you'll need to do is modify your reversion import locations, and everything will continue to work.

Happy coding!