When displaying the below choices, I want to be able to order them as follows Preparation, Review, Update, Finalised and Completed.
Right now, they are ordered alphabetically.
The below is a simple model:
class Choice(models.Model):
status_choices = [
("", "Select Current Status"),
("Preparation", "Preparation"),
("Review", "Review"),
("Update", "Update"),
("Finalised", "Finalised"),
("Completed", "Completed"),
]
current_status = models.CharField(
max_length=32,
choices = status_choices,
default = "Select current status",
)
class Meta:
ordering = ["current_status"]
I read that assigning a number in the Tuple can allow them to be ordered, which I tried per the below:
status_choices = [
("", "Select Current Status"),
("1", "Preparation"),
("2", "Review"),
("3", "Update"),
("4", "Finalised"),
("5", "Completed"),
]
However, this made no difference. I have also tried:
PREPARATION = "a"
REVIEW = "b"
UPDATE = "c"
FINALISED = "d"
COMPLETED = "e"
status_choices = [
("", "Select Current Status"),
(PREPARATION, "Preparation"),
(REVIEW, "Review"),
(UPDATE, "Update"),
(FINALISED, "Finalised"),
(COMPLETED, "Completed"),
]
I feel like this should be very simple but maybe not.