May 26, 2010

Generic views part 1

Problem with start page of your web app is most common: "Do I need to create view for index.html, just to allow loading the page ?". Well you don't. Take a look at the code below :
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

urlpatterns = patterns('',
      (r'^/$', direct_to_template, { 'template': 'index.html' })
)
What is this 'direct_to_template' import ? It's django's built-in view, that allows us to load template without specifying any view for it. More to come soon...

No comments:

Post a Comment