Migration? #173

23doors opened this Issue Mar 6, 2012 · 5 comments


None yet

5 participants


Is there any way to migrate existing model to MPTT model? South is asking me for default values for lft etc. What I have is a flat list and I want to add tree capabilities to it. Is there a way to build lft/rgt/tree_id after migration?


Setting '0' to default values while migrating seem to lead to this issue. Looks like mptt need a NULL parent when editing an item that has no parent.


@django-mptt is this rebuild() method implemented in the current PIP version?
Souldn't it also be MyModel.tree.rebuild()?
And what about what @viniciusmassuchetto said, is that true?
I'm having some trouble with that, and no answers till now.


Yes, rebuild() has been around for ages so it's in the current version. The tree manager in the latest version is .objects, but .tree still works too (it has a loud deprecation warning though.)

I must have missed @viniciusmassuchetto 's comment. Of course, you need to set parent_id correctly for all your nodes. If a node doesn't have a parent it should be null. Then run the rebuild() to rebuild the other fields (tree_id, lft, rght, level.)


Closing this as it's not really anything in itself. Related: #174, #195

@craigds craigds closed this Aug 6, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment