django-mptt ImportError

2019-07-15 11:50发布

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.

标签: django-mptt
1条回答
一纸荒年 Trace。
2楼-- · 2019-07-15 12:17

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!

查看更多
登录 后发表回答