I am attempting to build a model that will keep items in order when a user changes its position (this happens on a JS frontend).
I feel a 'float' is best, as this value will constantly be changing. I will be passing the value by a javascript application.
class Item(models.Model):
title = models.CharField("Title", max_length=10000, blank=True)
position = models.FloatField("Item position", blank=True, null=True)
So the data could be (super simplified example):
title | position
Charlie | 1
Mark | 2
Bruce | 3
When Mark's position changes, it would automatically change Charlies' to position value to 2
:
title | position
Charlie | 2
Mark | 1
Bruce | 3
How would I post
this information (API) so that django realises one title
belongs above another?