Django:显示选择值
models.py: class Person(models.Model): name = models.CharField(max_length=200) CATEGORY_CHOICES = ( ('M', 'Male'), ('F', 'Female'), ) gender = models.CharField(max_length=200, choices=CATEGORY_CHOICES) to_be_listed = models.BooleanField(default=True) description = models.CharField(max_length=20000, blank=True) views.py: def index(request): latest_person_list2 = Person.objects.filter(to_be_listed=True) return object_list(request, template_name='polls/schol.html', queryset=latest_person_list, paginate_by=5) 在模板上,当我调用时person.gender,我得到'M'or 'F'而不是'Male'or 'Female'。 如何显示值('Male'或'Female')而不是代码('M'/ 'F')?