tags:

views:

51

answers:

2

I there a way to render a html page without having a vide model in django? If a page is going to display static html?

Also, can I redirect to a html page instead of a url. For example, instead of doing this

return HttpResponseRedirect('form/success/')

can I do this

return HttpResponseRedirect('success.html')
A: 

For static HTML you could use Flatpages app.

You could also serve rendered templates (which could contain only static HTML) but you will need a view:

from django.shortcuts import render_to_response
def some_view(request):
   return render_to_response('sometemplate.html')

About redirection, basically you can't redirect to HTML page by just giving the filename, even if it were statically serverd by the web server you would still be using a URL that points to that file.

rebus
+2  A: 

You can render a template without a view using the generic view direct_to_template.

Redirecting to success.html isn't the way to go in django since success.html doesn't have an associated URL. You always have to bind the template to an url via a view (direct_to_template is a view which gets all its arguments from the conf in urls.py, but it's still a view)

Guillaume Esquevin