读书笔记:Django 模板开发(二)Views, URLs, and Generic Views

view是django的逻辑中枢, template只是显示,template本身的基础还是html,下面是一个html实现的跳转

url直接写在template里面不是个好习惯,因为这个太容易改变了,最好通过Context传递进去。


<html>
   <head>
   <title>Press Releases</title>
   </head>
   <body>
   <h1>Press Releases</h1>
   <ul>
   {% for press in press_list %}
   <li>
   <a href="/press/detail/{{ press.id }}/">
   {{ press.title }}</a>
   </li>
   {% endfor %}
   </ul>
   </body>
   </html>

读书笔记:Django 模板开发(二)Views, URLs, and Generic Views_第1张图片

generic views    是对之前的view的流程的一些简化,考虑到网站开发过程中不断的拓展不建议使用。


你可能感兴趣的:(读书笔记:Django 模板开发(二)Views, URLs, and Generic Views)