#*.py#
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.db import connection, transaction
def Getab_type(request):
cursor=connection.cursor()
sql="SELECT F_Id,F_Name FROM tab_type "
cursor.execute(sql)
tab_types=cursor.fetchall()
cursor.close()
listype=[]
for i in range(0,len(tab_types)):
itype={'id':tab_types[i][0],'name':tab_types[i][1]}
listype.append(itype)
return render_to_response('show.html',{'listype':listype})
#模板 tpl#
<body>
<ul>
{%for itype in listype%}
<li>{{itype.id}}--{{itype.name}}</li>
{%endfor%}<ul></body>