user1990524 user1990524 - 1 year ago 117
Python Question

How to return a static HTML file as a response in Django?

I have not figured out how I can present a website with pure HTML code and/or HTML + JavaScript + CSS.

I tried to load a HTML file with that just says: Hello World.

I know I can do that with Django too, but later on I want to display my website with CSS+JavaScript+HTML.

In the views file I run this code:

# Create your views here.
from django.http import HttpResponse
from django.template import Context, loader

def index(request):
template = loader.get_template("app/index.html")
return HttpResponse(template.render)

But the only thing the website displays is:


Answer Source

You are not calling the render method there, are you?



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download