1. preparation [plain] django-admin.py startproject web01 django-admin.py startapp tim python manage. py runserver 2. settings register [python] INSTALLED_APPS = ('django. contrib. auth ', 'django. contrib. contenttypes ', 'django. contrib. sessions ', 'django. contrib. sites ', 'django. contrib. messages ', 'django. contrib. staticfiles ', 'Tim',) 3. configure url [python] from django. conf. urls. defaults import patterns, include, url urlpatterns = patterns ('', url (R' ^ tim/current/$ ', 'Tim. views. current '), # map views. current url (R' ^ tim/plus/(\ d {1, 2})/$ ', 'Tim. views. ahead'), # convert the numeric part to a tuples to be conveniently set to offset.) 4. views file. You do not need to import external html files here, so you do not need loader or Context. [python] # coding: utf8 from django. http import HttpResponse import datetime def current (req): now = datetime. datetime. now () html = 'the current time is % s' % now return HttpResponse (html) def ahead (req, offset): # Here the offset is only the input value obtained from the url, variable names can actually be any try: offset = int (offset) alias t ValueError: raise Http404 () dt = datetime. datetime. now () + datetime. after timedelta (hours = offset) html = '% s hour, the time will change to % s' % (offset, dt) # After the offset hour, the time will change to dt return HttpResponse (html)