我创建了这样的UserProfile数据模型:
class UserProfile(models.Model):
STATUS = (
(1, 'male'),
(0, 'lady'),
)
user = models.OneToOneField(User, on_delete=models.CASCADE)
gender = models.IntegerField(choices=STATUS, default=1)
该模板应显示描述性性别:
<div class="row">
<div class="col-md-4 text-right"><span>Gender:</span></div>
<div class="col-md-8 text-left"><span>{{ user_profile.gender }}</span></div>
</div>
但是它显示
Gender: 1 rather than Gender:male
如何使模板显示描述性性别?