问题描述
我已经安装了django-mptt,并遵循了有关为MPTT建立Django模型
I have installed django-mptt and have followed the documentation regarding setting up a Django model for MPTT
但是,我收到以下ImportError:
However, I am getting the following ImportError:
from mptt.models import MPTTModel, TreeForeignKey
ImportError: cannot import name TreeForeignKey
任何人都可以帮忙吗?
任何建议表示赞赏.
谢谢.
推荐答案
TreeForeignKey是在文件fields.py中定义的类.似乎该文件是最近才添加到v0.5.pre的代码库中的.
TreeForeignKey is a class defined in the file fields.py. It looks like this file was just recently added to the code base for v0.5.pre.
如果您使用的是0.4.2或更早版本,则此文件和类不存在.我不确定在没有此类的情况下如何使用此软件包,因为该文档仅适用于最新版本的代码(v0.5.pre).
If you are using version 0.4.2 or older, this file and class don't exist. I'm not sure how this package is intended to be used without this class, since the documentation only applies to the latest version of the code (v0.5.pre).
祝你好运!
这篇关于django-mptt ImportError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!