Direct to Template

Created on Sept. 20, 2012, 10:52 p.m. by Hevok & updated by Hevok on May 2, 2013, 5:24 p.m.

URLconf (urls.py) is the mapping between urls and functions (views.py). When the user click triggers the url the function will be executed, prepares the data (e.g. by fetching from a database) and returns always a HttpResponse object which can use a template. direct_to_template allows to omit the function and directly tell which page to go: ::

nano urls.py
from django.conf.urls.defaults import patterns, url
from django.views.generic.simple import direct_to_template


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

Tags: tutorial, python, django
Parent: Web Framework

Update entry (Admin) | See changes

Comment on This Data Unit