开发者

Render Template Exactly with Django

I'm a complete newb to Django working on a sample app. It appears that I am missing something with how templates work in Django.

I have a template file as follows:

<!DOCTYPE HTML>
<html>
<head>
<title>Zabba Dabba Doo</title>
</head>
<body>
<h1>Zabba Dabba Doo</h1>

<form action="/comparison/search/" method="get">
Search: <input type="text" name="search_terms" />
<input type="submit" value="Search" />
</form>

</body>
</html>

The views.py method is here:

def home(request):
   t = loader.get_template('comparison/index.html')
   return HttpResponse(t)

I am开发者_StackOverflow中文版 expecting the views method to render the html from my template, but when I test it, this is the resulting output:

<Text Node: '<!DOCTYPE HTML>
<html>
<h'>

Can anyone explain to me how to make it so my template is displayed exactly? Any help is appreciated.


You forgot to render it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜