I would like to display priority information in a drop down. Currently i am using a integer field to store the priority, but i would like to display high/medium/low instead of letting user type in a priority.
A way to approximate this is to use a Priority database which stores 3 elements, 1:high, 2:medium, 3:low, but it seems like an overkill.
Any easier way would be much appreciated!
Jason
You can specify choices for a field http://www.djangoproject.com/documentation/models/choices/.
PRIORITY_CHOICES = ((1, 'High'),
(2, 'Medium'),
(3, 'Low'))
class MyModel(models.Model):
priority = models.IntegerField(choices=PRIORITY_CHOICES)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With