我在models.py中定义了如下choices
class Node(models.Model):
GroupChildType = (
('nochild', '无子节点'),
('or', '分类'),
('and', '核心'),
)
childtype = models.CharField(max_length=20, choices=GroupChildType)
在模板中渲染完成后直接输出了'nochild',并没有输出'无子节点',请问如何才能让模板中显示后面的value值呢?
views.py
def index(request):
nodes = Node.objects.all()
return render_to_response('index.html', {'nodes': nodes, 'user': request.user}, context_instance=RequestContext(request))
index.html
<h3 class="panel-title">{{ node.childtype }}</h3>
我希望在模板中输出 无子节点,而不是nochild。大家帮帮忙,谢谢了。