Hello,
when inserting nodes from the django admin interface it looks like the order_insertion_by value is not respected.
This is my model:
@python_2_unicode_compatible
class Section(MPTTModel):
summary = models.ForeignKey(Sommario)
title = models.CharField(max_length=1024)
page = models.IntegerField()
parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True)
def __str__(self):
return u'{} - p. {}'.format(self.title,
self.page)
class Meta:
verbose_name_plural = u'Sections'
class MPTTMeta:
order_insertion_by = ['page',]
This is the tree before insertion:
pk,level,parent_id,tree_id,lft,rght,pretty
66647,0,,49,1,2,ARTE IN PRATICA - p. -4
66549,0,,178,1,6,PREISTORIA - p. 4
66550,1,66549,178,2,3,- 1 - L’arte rupestre nel Paleolitico - p. 4
66551,1,66549,178,4,5,- 2 - Pitture e graffiti nel Neolitico - p. 5
66552,0,,623,1,8,LE ANTICHE CIVILTÀ - p. 6
66553,1,66552,623,2,3,- 1 - Architetture monumentali - p. 6
66554,1,66552,623,4,5,- 2 - La religione egizia - p. 7
66555,1,66552,623,6,7,- 3 - L’architettura in Mesopotamia - p. 8
66556,0,,1274,1,16,L’ANTICA GRECIA - p. 15
A this is after insertion:
pk,level,parent_id,tree_id,lft,rght,pretty
66647,0,,49,1,2,ARTE IN PRATICA - p. -4
66549,0,,178,1,6,PREISTORIA - p. 4
66550,1,66549,178,2,3,- 1 - L’arte rupestre nel Paleolitico - p. 4
66551,1,66549,178,4,5,- 2 - Pitture e graffiti nel Neolitico - p. 5
67197,0,,408,1,2,proa - p. 10
66552,0,,624,1,8,LE ANTICHE CIVILTÀ - p. 6
66553,1,66552,624,2,3,- 1 - Architetture monumentali - p. 6
66554,1,66552,624,4,5,- 2 - La religione egizia - p. 7
66555,1,66552,624,6,7,- 3 - L’architettura in Mesopotamia - p. 8
66556,0,,1275,1,16,L’ANTICA GRECIA - p. 15
I'd expect to have page 10 inserted between page 6 and 15, but it's inserted between 4 and 6.
I'm on django 1.11.12 and django-mptt 0.9.0.
Any hint on what could be wrong?
Thanks in advance,
Riccardo