EMP_CHOICES = ( (0,'-- Select --'), (1,'Good'), (2,'Average'), ) class EMPFeedback(models.Model): user_choices = models.IntegerField(choices=EMP_CHOICES)
如果存储在db中的user_choices值为1,如何打印对应的user_choices对应值(即1 == GOOD)
fb = EMPFeedback.objects.get(id=1) print fb.user_choices # prints 1 print fb.user_choices.EMP_CHOICES
fb.get_user_choices_display()