I would like to get the named values of a choices field for a choice that is not currently selected. Is this possible?
For instance: models.py
FILE_STATUS_CHOICES = (
('P', 'Pending'),
('A', 'Approved'),
('R', 'Rejected'),
)
class File(models.Model):
status = models.CharField(max_length=1, default='P', choices=FILE_STATUS_CHOICES)
views.py
f = File()
f.status = 'P'
f.save()
old_value = f.status
print f.get_status_display()
> Pending
f.status = 'A'
f.save()
new_value = f.status
print f.get_status_display()
> Approved
How can I get the old display value from the 'P' to 'Pending?' I may be able to do so by creating a form in the view and accessing its dictionary of values/labels. Is this the best/only approach?