We’re all good now, thanks. That helps a lot!
What you’re looking for then is another field in your tasks to identify the sequence number.
example:
class Task(models.Model):
task_id = models.IntegerField(primary_key=True, editable = False,)
game = models.ForeignKey(Game, on_delete=models.CASCADE)
task_order = models.IntegerField()
title = models.CharField(max_length=255)
description = models.TextField()
[...]
class Meta:
order_with_respect_to = 'game'
unique_together = ['game', 'task_order']
In your view, you can set the task_order value to the index number of the task in your list.
Then, you can either set ordering
to task_order
to make it the default sort, or you use the order_by
method on your queries when it’s needed.
For being able to edit this within the admin, you’re either going to need to craft your own solution, or pick a third-party package to help. I don’t believe there’s anything in Django core to facilitate this. There are some packages available - I haven’t used any so I don’t know how well they work or whether or not they fit your requirements.
In general terms, when I’m looking for third party packages, I start with djangopackages.org. For your particular case, I’d look at either Model Ordering or possibly Admin Interface.