I have a little problem with django-mptt 0.6.0. I have model MyModel with standard parent field and register as mptt-model through mptt.register(MyModel). I create MyModel instance obj_1 with None parent as 0 level object. After this i create MyModel instance obj_2 with None parent also as 0 level object. I try to change obj_2 parent value from None to obj_1. When I call save method of obj_2, mptt raise
AttributeError: 'NoneType' object has no attribute 'tree_id'.
Problem at mptt/models.py:782 line, where we try do this:
getattr(self, opts.tree_id_attr) != getattr(parent, opts.tree_id_attr)
This error raised, because before this we have 2 step:
opts.set_raw_field_value(self, opts.parent_attr, old_parent_id)
- where old_parent_id is Noneparent = getattr(self, opts.parent_attr)
- where parent, of course, also is NoneIs that bug?
In [16]: o1 = Category()
In [17]: o2 = Category()
In [18]: o1.save()
In [19]: o2.parent = o1
In [20]: o2.save()
--
You received this message because you are subscribed to the Google Groups "django-mptt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-mptt-d...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
It seems that settinghttps://github.com/django-mptt/django-mptt/issues/428parent_id
does not resetparent
in any way, resp.parent
isn't dynamically loaded from the database just because the underlying id field has some value.