At present we figure out where to insert new nodes in get_ordered_insertion_target(), which gets called from save() before the superclass's save() gets called.
This is kind of bad because it means field.pre_save() hasn't yet been called for the relevant fields.
As a result, specifying a datetime field with auto_add_now=True in insertion_order_by will not currently work, because the value is not set until field.pre_save() is called. Reported in this SO post: http://stackoverflow.com/questions/9596115/how-to-order-django-mptt-tree-by-datetimefield
I can confirm that this causes problems not just when using an auto_add_now in order_insertion_by, but also when you have any auto_now fields in the model. None of the date fields I have in my model are being used as order_insertion_by fields, and I get the same error as indicated on the SO post. The workaround doesn't work for me.
Have confirmed this problem as well with an automatically filled Integer ordering field.
@dokterbob how is the integer field auto-filled? Can you post your model definition?
fix usage of date fields with auto_now_add in order_insertion_by. @do…
…kterbob / @movielady please confirm this fixes the problem (closes #175)
Will look at the patch on monday maybe, rest of the week will be Djangocon. :)
Maybe I'll see you there
The patch didn't solve the issue for me.
Setting the ordering attribute from the clean() method as recommended by the Django docs versions did, however. Perhaps we should have a word about this in the docs?