使用django-mptt和django auth_user

时间:2014-03-05 09:32:38

标签: python django django-models django-mptt

我正在尝试使用django-mptt创建用户树。我有auth_user表和一对一映射表UserProperties,其外键为auth_user。 我在用户表上的TreeForeignKey模型(UserProperties列)中添加了parent django-mptt。但是在创建具有以下错误的对象时失败:

'User' object has no attribute 'is_root_node'

1 个答案:

答案 0 :(得分:2)

The method (not attribute) 'is_root_node()' is valid on query-items

item = Class.objects.get()

or in iterator or list expression:

[item.is_root_node() for item in Class.objects.filter(name = 'name')]

But to address your question properly, could you give us the code for your model and your query, please.