def save(self, *args, **kwargs):
        if not self.pk:
            try:
                # Although we dont actually want to include ourselfs, since we are not
                # inserted to the db, we cannot be excluded from the query.
                self.position = self.siblings(include_self=True).only('position').order_by('-position')[0].position + 1
            except __HOLE__:
                if self.parent:
                    self.position = self.parent.position + 1
                else:
                    try:
                        self.position = Forum.objects.only('position').order_by('-position')[0].position + 1
                    except IndexError:
                        self.position = 1
            
            if self.position != 1:
                Forum.objects.update_position(self.position)
            
            if self.parent:
                self.level = self.parent.level + 1
        super(Forum, self).save(*args, **kwargs)
dataset/ETHPy150Open kylef-archive/lithium/lithium/forum/models.py/Forum.save