Python Django Template
Link up on an article
First, create a template file
# Cat Blog/template/index.html
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd XHTML 1.0.5 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8"/>
<title>csvt</title>
<body>
</body>
Ii. Publishing template files to a view method
(1) The first method:
# Cat blog/views.py
From django.http import HttpResponse
From django.template import Loader,context
def index (req):
t = loader.get_template (' index.html ')
c = Context ({})
Return HttpResponse (T.render (c))
(2) The second method:
# Cat blog/views.py
From django.shortcuts import Render_to_response
def index (req):
Return Render_to_response (' index.html ', {})
The same results can be obtained by accessing http://192.168.116.129/blog/index/through the browser
This article is from "Meteor Yu" blog, please be sure to keep this source http://8789878.blog.51cto.com/8779878/1850739
Third, Python Django template