Manual ordering
ManualOrderModel adds an integer order_key. Instances are ordered by
ascending key, so 0 is first.
from blueprint.models import ContentModel, ManualOrderModel
class Section(ContentModel, ManualOrderModel):
title = models.CharField(max_length=200)
Section.objects.create(title="Intro", order_key=1)
Section.objects.create(title="Body", order_key=2)
Renumbering​
The reorder() method normalizes the keys to a gapless 1..n sequence,
preserving the current order:
section = Section.objects.first()
section.reorder()
# Every instance now has order_key 1, 2, 3, ... in current order
Use it after the user has finished dragging items around and you have saved sparse keys.