django (template language)

Template language is written in html

cur_time.html 

<
body > < h1 > Current time: {{ currenttime }} </ h1 > //{{}} is a variable </ body > </ html >


views.py

def cur_time(req): 
curtime=datetime.datetime.now()
return render(req,"cur_time.html",{"currenttime":curtime}) #Replace the currenttime variable in the front end with curtime in the back end
# return HttpResponse("<h1>nihoa</h1>")
 
<table border="1">
    {% for i in info_list %} //{%%} is a statement
        <tr>
            <td>{{ i.username }}</td>
            <td>{{ i.pwd }}</td>
        </tr>
    {% endfor %}
</table>


views.py
def userInfo(r): 
return render(r, "userInfo.html",{"info_list":info_list}) #Replace the info_list in the front end with the info_list in the back end
 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325282515&siteId=291194637