我正在尝试使用django-mptt
创建用户树。我有auth_user
表和一对一映射表UserProperties
,其外键为auth_user
。
我在用户表上的TreeForeignKey
模型(UserProperties
列)中添加了parent
django-mptt。但是在创建具有以下错误的对象时失败:
'User' object has no attribute 'is_root_node'
答案 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.