What is direct_to_template in django?

Usually in django,

urls.py provides mapping between a url and a python function (that is, when a user clicks the url, the python function will be executed.)

The python function is usually defined at views.py

——

In a simple word, with direct_to_template, we don’t need views.py. It directly tells which page to go.

E.g.,

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

urlpatterns = patterns('',
    ('^about/$', direct_to_template, {
        'template': 'about.html'
    })
)

Leave a comment