[英]Why choice field displays keys instead of values in django queryset?
I have a Choice Field in my models.py我的models.py中有一个选择字段
models.py模型.py
STATUS = (
('closed_issue', 'Closed Issue'),
('open_ssue', 'Open Issue'),
('pending', 'Pending'),
)
class Issue(models.Model):
name = models.CharField(max_length=45)
status = models.CharField(max_length=50, choices=STATUS)
views.py视图.py
def Issues(resuest):
issues = Issue.objects.all()
template模板
{% for issue in issues %}
{{ issue.status }}
{% endfor %}
output输出
closed_issue open_issue closed_issue open_issue
It displays the keys of the choice field instead of values它显示选择字段的键而不是值
I want the values to be displayed in the template.我希望这些值显示在模板中。 Is there a way to get the values instead of keys?
有没有办法获取值而不是键?
Thanks for any help.谢谢你的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.