index.html

 {{ user_dict.k1 }}
    <ul>
        {% for k,row in user_dict.items %}
            <li><a  target="_blank"  href="/CC/detail/?nid={{ k}}">{{ row.name }}</a></li>
        {% endfor %}
    </ul>
    <p>_______________________________________________________</p>
    <ul>
        {% for k,row in user_dict.items %}
            <li><a  target="_blank"  href="/CC/detail-{{ k}}.html">{{ row.name }}</a></li>
        {% endfor %}
    </ul>

    <ul>
        {% for k in user_dict.keys %}
            <li>{{ k }}-</li>
        {% endfor %}
    </ul>
    <ul>
        {% for row in user_dict.values %}
            <li>-{{ row }}</li>
        {% endfor %}
    </ul>

  后台代码:

USER_DICT={
    "1":{"name":"root1","email":"123"},
    "2":{"name":"root2","email":"123"},
    "3":{"name":"root3","email":"123"},
    "4":{"name":"root4","email":"123"},
}
def index(request):
    return  render(request,"index1.html",{'user_dict':USER_DICT})

  

def detail(request):
    print '2222222222222',request.GET
    nid =request.GET.get("nid")
    detail_info = USER_DICT[nid]
    return render(request,'detail.html',{"dict":detail_info})

  detail.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
        <h3>详细信息</h3>
        <p> name :{{ dict.name }}</p>
        <p> email :{{ dict.email }}</p>


</body>
</html>

  

  

 

相关文章:

  • 2022-12-23
  • 2021-12-29
  • 2021-11-06
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-05-17
  • 2022-12-23
相关资源
相似解决方案