问题
My Django 1.7.1 application runs fine. But I would like to upgrade to the more recent version 1.8.2. I'm following the instructions here which basically just say to do pip install -U Django
from within my VirtualEnvironment.
After I do that line though, I Immediately try to do manage.py
and it fails as shown below.
Can someone suggest to me what I should do to fix this? The errors below look like they have something to do with the MPTT module. (I'm running version 0.6.1 of MPTT). Upgrading to a newer version of django-mptt
as well comes with its own set of messy headaches.
(myVirtualEnv) $ ./manage.py
myVirtualEnv/src/django-cache-machine-origin/caching/invalidation.py:21: RemovedInDjango19Warning: 'get_cache' is deprecated in favor of 'caches'.
cache = get_cache('cache_machine')
myVirtualEnv/lib/python2.7/site-packages/mptt/forms.py:7: RemovedInDjango19Warning: The django.forms.util module has been renamed. Use django.forms.utils instead.
from django.forms.util import ErrorList
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "myVirtualEnv/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "myVirtualEnv/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "myVirtualEnv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "myVirtualEnv/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "myVirtualEnv/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "myProject/myApp1/models.py", line 5, in <module>
from categories.models import Category
File "myProject/myApp2/models.py", line 22, in <module>
class Category(CachingMixin, MPTTModel):
File "myVirtualEnv/lib/python2.7/site-packages/mptt/models.py", line 244, in __new__
cls = meta.register(cls)
File "myVirtualEnv/lib/python2.7/site-packages/mptt/models.py", line 338, in register
tree_manager.init_from_model(cls)
File "myVirtualEnv/lib/python2.7/site-packages/mptt/managers.py", line 52, in init_from_model
[tree_field] = [fld for fld in model._meta.get_fields_with_model() if fld[0].name == self.tree_id_attr]
File "myVirtualEnv/lib/python2.7/site-packages/django/db/models/options.py", line 56, in wrapper
return fn(*args, **kwargs)
File "myVirtualEnv/lib/python2.7/site-packages/django/db/models/options.py", line 432, in get_fields_with_model
return [self._map_model(f) for f in self.get_fields()]
File "myVirtualEnv/lib/python2.7/site-packages/django/db/models/options.py", line 740, in get_fields
return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
File "myVirtualEnv/lib/python2.7/site-packages/django/db/models/options.py", line 802, in _get_fields
all_fields = self._relation_tree
File "myVirtualEnv/lib/python2.7/site-packages/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "myVirtualEnv/lib/python2.7/site-packages/django/db/models/options.py", line 709, in _relation_tree
return self._populate_directed_relation_graph()
File "myVirtualEnv/lib/python2.7/site-packages/django/db/models/options.py", line 681, in _populate_directed_relation_graph
all_models = self.apps.get_models(include_auto_created=True)
File "myVirtualEnv/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "myVirtualEnv/lib/python2.7/site-packages/django/apps/registry.py", line 168, in get_models
self.check_models_ready()
File "myVirtualEnv/lib/python2.7/site-packages/django/apps/registry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
回答1:
I hate to be the bearer of bad news, but you've run into something that's one of the most hellish bits of developing with Django: trying to get all of your dependencies to the right version to work with each other. It's not uncommon for a specific version of a dependency to be dependent on specific versions of Django.
mptt does not support Django 1.8 until version 0.70 (see upgrade notes: http://django-mptt.github.io/django-mptt/upgrade.html) . So if you want Django 1.8, you're going to have to upgrade mptt first. Sorry.
回答2:
I do not have enough privilege to comment, but you may try if the answer from this post helps your problem.
来源:https://stackoverflow.com/questions/31107287/upgrading-from-django-1-7-1-to-1-8-2-fails