我的Django 1.7.1应用程序运行正常。但我想升级到更新版本1.8.2。我按照here的说明操作,基本上只是说我在虚拟环境中执行pip install -U Django
。
在我这样做之后,我立即尝试manage.py
,它失败了,如下所示。
有人可以告诉我应该怎么做才能解决这个问题?下面的错误看起来与MPTT模块有关。 (我正在运行MPTT的0.6.1版本)。升级到更新版本的django-mptt
也会带来一系列令人头疼的麻烦。
(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.
答案 0 :(得分:2)
我讨厌成为坏消息的承载者,但是你遇到了一些与Django一起开发的最糟糕的事情之一:尝试将所有依赖关系转换为正确的版本以便彼此协作。特定版本的依赖项依赖于Django的特定版本并不罕见。
mptt在版本0.70之前不支持Django 1.8(参见升级说明:http://django-mptt.github.io/django-mptt/upgrade.html)。所以如果你想要Django 1.8,你将不得不首先升级mptt。遗憾。
答案 1 :(得分:1)
我没有足够的权限发表评论,但您可以尝试this post的答案可以帮助您解决问题。