I have the following model in django:
class Page(models.Model):
page_number = models.IntegerField()
...
and I would like to make sure that this page number keeps being a sequence of integers without gaps, even if I delete some pages in the middle of the existing pages in the data base. For example, I have pages 1, 2 and 3, delete page 2, and ensure page 3 becomes page 2.
At the moment, I am not updating the page_number, but rather reconstructing an increasing sequence without gaps in my front end by:
- querying the pages
- sorting them according to page_number
- assigning a new
page_order
which is incremental and without gaps
But this does not seem to the be best way to go...