# In views def zbsservice(request): #返回一个列表 v1 = models.Business.objects.all() # .value返回一个字典 v2 = models.Business.objects.all().values("id","caption","code") # .values_list 返回一个元组 v3 = models.Business.objects.all().values_list('id','caption') return render(request,'zbsservice.html',{ 'v1':v1,'v2':v2,'v3':v3}) # In html{ % endfor %}ServiceName:(列表)
{ % for item in v1 %}
ServiceName:(字典)
{ % for item in v2 %} { % endfor %}ServiceName:(元组)
{ % for item in v3 %} { % endfor %}