django-mptt ImportError

我只是一个虾纸丫 提交于 2019-12-24 03:04:49

问题


I have installed django-mptt and have followed the documentation regarding setting up a Django model for MPTT

However, I am getting the following ImportError:

 from mptt.models import MPTTModel, TreeForeignKey
 ImportError: cannot import name TreeForeignKey

Can anyone help?

Any advice appreciated.

Thanks.


回答1:


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.

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).

Good Luck!



来源:https://stackoverflow.com/questions/5781352/django-mptt-importerror

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!