ThomasMX
ThomasMX

Reputation: 1822

Why is django not showing the content what I declare in template?

I have the following in the templates/index.html

<!DOCTYPE html>
<html>
<head>
    <title>Rango</title>
</head>

<body>
    <h1>Rango says...</h1>
    hello world! <strong>foo</strong><br />
    <a href="/rango/about/">About</a><br />
</body>

How ever, the output is the following (page source)

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

 '>

What could be the reason?

EDIT:

Here is my view code:

from django.shortcuts import render
from django.http import HttpResponse
from django.template import RequestContext, loader



# Create your views here.

def index(request):
    template = loader.get_template('index.html')

    return HttpResponse(template)

Upvotes: 0

Views: 68

Answers (1)

laidibug
laidibug

Reputation: 1219

You need to render the template in the view. Try the render_to_response shortcut. Otherwise show us the view code.

Upvotes: 1

Related Questions