[Django]-Model_mommy breaks django-mptt

3👍

Turns out that if lft or rght have a truthy value, MPTTModel.save considers the node to already have been set up. Thus setting these fields to None is enough to fix the tree update.

I created a mommy recipe that I use everywhere in my tests, so I don’t have to remember to set these fields:

category_recipe = Recipe(Category, lft=None, rght=None)

And then in the test cases: category_recipe.make() instead of mommy.make(Category).

Leave a comment