[经验随手记]Django 之 template 与 view

1. 写view

在工程目录下的views.py中写view 函数,譬如,用render_to_response('xx.html', {'oo': oo})这种形式,第二个参数需要形成一个dictionary,而这个oo可以是string, list, dict等


2. 写template

在自设的template目录下写xx.html文件

比如要显示一个名为value的list(该list的元素是一个(k,v) tuple):


   <table>
   {% for k,v in values %}
       <tr> <td> {{k}} </td> <td>{{v}}</td></tr>
   {% endfor %}
   </table>


你可能感兴趣的:(python,django)