| Issue 32: | Updating nodes causes incorrect MPTT fields on other nodes | |
| 3 people starred this issue and may be notified of changes. | Back to list |
I have:
mptt.register(ContentNode, order_insertion_by=['order'])
and the following doctest:
>>> english_node = ContentNode(slug='en', title='English')
>>> english_node.save()
>>> about_node = ContentNode(slug='about', title='About', parent=english_node, order=1)
>>> about_node.save()
>>> contact_node = ContentNode(slug='contact', title='Contact', parent=english_node, order=2)
>>> contact_node.save()
>>> english_node = ContentNode.objects.get(pk=english_node.pk) # Refresh, otherwise get_children() returns []
>>> english_node.get_children()
[<ContentNode: "About">, <ContentNode: "Contact">]
that is failing with:
Failed example:
english_node.get_children()
Expected:
[<ContentNode: "About">, <ContentNode: "Contact">]
Got:
[<ContentNode: "Contact">, <ContentNode: "About">]
Even though Contact has order=2 About has order=1.
Oct 30, 2008
The same problem occurs if you are not using an explicit order field. In order to get this to work properly for the "no order field" case, I have to create the contact_node without a parent and then call: ContentNode.tree.insert_node(contact_node,about_node,position="right",commit=True) Using insert_node to attach to the english_node with position="last_child" fails the same way that ot does in your example.
Sep 3, 2010
(No comment was entered for this change.)
Summary:
Updating nodes causes incorrect MPTT fields on other nodes
Status: Accepted Owner: craig.ds
Nov 12, 2010
(No comment was entered for this change.)
Status:
Duplicate
Mergedinto: 78 |
Owner: jonathan.buchanan