简体   繁体   English

从Django 1.7.1升级到1.8.2失败

[英]Upgrading from Django 1.7.1 to 1.8.2 fails

My Django 1.7.1 application runs fine. 我的Django 1.7.1应用程序运行良好。 But I would like to upgrade to the more recent version 1.8.2. 但是我想升级到更新的版本1.8.2。 I'm following the instructions here which basically just say to do pip install -U Django from within my VirtualEnvironment. 我按照这里的说明进行操作这些说明基本上只是说要从我的VirtualEnvironment内部进行pip install -U Django

After I do that line though, I Immediately try to do manage.py and it fails as shown below. 但是,在执行该行之后,我立即尝试执行manage.py ,但操作失败,如下所示。

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. 以下错误似乎与MPTT模块有关。 (I'm running version 0.6.1 of MPTT). (我正在运行MPTT的0.6.1版)。 Upgrading to a newer version of django-mptt as well comes with its own set of messy headaches. 升级到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.

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. 我不愿成为坏消息的承担者,但是您遇到了一些使用Django开发时最可笑的事情:尝试使所有依赖项都达到正确的版本以相互配合。 It's not uncommon for a specific version of a dependency to be dependent on specific versions of Django. 特定版本的依赖项依赖于特定版本的Django并不少见。

mptt does not support Django 1.8 until version 0.70 (see upgrade notes: http://django-mptt.github.io/django-mptt/upgrade.html ) . mptt直到版本0.70才支持Django 1.8(请参阅升级说明: 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. 因此,如果您想使用Django 1.8,则必须先升级mptt。 Sorry. 抱歉。

我没有足够的特权发表评论,但您可以尝试是否这篇文章的答案可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM