Change: Direct to Template

created on Sept. 20, 2012, 10:52 p.m. by Hevok & updated on Oct. 14, 2012, 9:41 p.m. by Hevok

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'})
)

Categories:
Parent: Tutorials

Comment: Updated Entry

See entry | Admin

Comment on This Data Unit