views 返回数据
from django.shortcuts import render
Create your views here
from django.http import HttpResponse from .models import yiqing1 from .models import numbers
def index(request): numbers_info=numbers.objects.all() numberlist=[]
countrylist=[]
for i in numbers_info:
numberlist.append(i.number)
countrylist.append(i.country)
print("------------------------")
print(numberlist)
print()
print('-----------')
all_info=yiqing1.objects.all()
print(all_info)
time_list=[]
qz_list=[]
sw_list=[]
zy_list=[]
for i in all_info:
time_list.append(i.time_info)
qz_list.append(i.qz)
sw_list.append(i.sw)
zy_list.append(i.zy)
print(time_list)
print(qz_list)
print(sw_list)
print(zy_list)
# return HttpResponse("ddd")
# return render(request,'index.html')
return render(request,"index.html",{'time_list':time_list,'qz_list':qz_list,'sw_list':sw_list,'zy_list':zy_list,'numberlist':numberlist,'countrylist':countrylist})
# # # return render(request,'')
为什么只有countrylist是无法用{{}}获取到数据的,大家都是数组,不同的是countrylist里面是中文,其他是数字,有没有大佬能解决一下
评论 1
‘l'’