0
장고 - mptt은 'NoneType'객체가 될 때 노드를 저장하는 'tree_id'에는 속성이 없습니다 제기
환경 : 파이썬 2.7.10, 장고 1.9.1, 장고 - mptt 0.8.4
# models.py
class Foo(MPTTModel):
parent = TreeForeignKey('self', null=True, blank=True)
오류에 제기
getattr(self, opts.tree_id_attr) != getattr(parent, opts.tree_id_attr)
부모가
None
때문이다
:
1) link
opts.set_raw_field_value(self, opts.parent_attr, old_parent_id) # old_parent_id is None
2) link
def set_raw_field_value(self, instance, field_name, value):
field = instance._meta.get_field(field_name)
setattr(instance, field.attname, value)
parent = getattr(self, opts.parent_attr)
이 동작을 이해하는 데 도와주세요. 왜 관계를
self.parent_id
으로 설정하는 것으로 충분하지 않습니까?