django-模板之comment标签(六)

前端之家收集整理的这篇文章主要介绍了django-模板之comment标签(六)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset=UTF-8">
    <title>{{title}}</title>
    <style>
        .header {
            height: 50px;
            background-color: fuchsia;;
        }
        .content{
            height:300px;
        }
        .footer{
            height:50px;
            background-color: thistle;
        }
    </style>
</head>
<body>
    <div class=header">Nav Area</div>
    <div content">
        {% for letter in letters %}
         {
% comment %} <h1>{{letter}}</h1>        {% endcomment %} <h1>{{letter}}</h1> {% endfor%} {% block content %} {% endblock %} </div> <div footer">Foot Area</div> </body> </html>

comment标签用于注释

for标签用于读取列表并显示

book/views.py

from django.shortcuts import render

def index(request):
    requests={
        'letters':[a',bcd']
    }
    return render(request,1)">index.html",context=requests)

 

猜你在找的Django相关文章