def save(self, force_insert=False, force_update=False, using=None):
        """
        Calculate position (max+1) for new records
        """
        if not self.position:
            max = self.__class__.objects.filter().aggregate(models.Max('position'))
            try:
                self.position = max['position__max'] + 1
            except __HOLE__:
                self.position = 1
        return super(OrderableModel, self).save(force_insert=force_insert, force_update=force_update, using=using)
dataset/ETHPy150Open baskoopmans/djcommon/djcommon/models.py/OrderableModel.save