Preparation [plain] django-admin.py startproject web02 [Create a web02 project] django-admin.py startapp blog [Create an application named blog] then create a folder under the blog, templates, place the html template. Python manage. py runserver [start django Development Server] Go to settings. py and register the newly created application. [Python] INSTALLED_APPS = ('django. contrib. auth ', 'django. contrib. contenttypes ', 'django. contrib. sessions ', 'django. contrib. sites ', 'django. contrib. messages ', 'django. contrib. staticfiles ', 'blog',) first configure views. py View File [python] # encoding: utf8 from django. http import HttpResponse from django. template import loader, Context class Person (object): def _ init _ (self, name, age, sex): self. name = name self. age = Age self. sex = sex def say (self): return self. name + ''+ str (self. age) + ''+ self. sex def index (req): tsf-loader.get_template('index.html ') # load the template file name = 'Tom 'age = 23 sex = 'male' title = 'emp' marry = True booklist = ['python', 'php ', 'java'] booktuple = ('A', 'B', 'C') books = {'A': 'python', 'B ': 'C ++ '} zhangsan = Person ('hangsan', 23, 'male') c = Context ({# Load file content 'name': name, 'age': age, 'sex': sex, 'title': title, 'Marry': marry, 'booklist': booklist, 'bookuple': booktuple, 'books ': books, 'zhangsan': zhangsan,}) html = t. render (c) # return HttpResponse (html) with the template rendering content # return the rendered content def add (req): # the previous index is the focus of the description, the following three are the simplest cases: return HttpResponse ('add list') def dele (req): return HttpResponse ('delete list') def select (req ): return HttpResponse ('select list') and then configure urls. py, after the configuration, these pages can be accessed. [Python] # coding: utf8 from django. conf. urls. defaults import patterns, include, url urlpatterns = patterns ('', url (R' ^ blog/index/$ ', 'blog. views. index'), # If the first half matches the regular expression, the second half calls the index Method url (R' ^ blog/add/$ ', 'blog. views. add'), url (R' ^ blog/dele/$ ', 'blog. views. dele'),) urlpatterns + = patterns ('blog. views ', # This can be used as the prefix. In addition, patterns can overwrite URLs (R' ^ blog/select/$', 'select'). Here, index is used as an example, edit the index in the templates folder. ht Ml file, focusing on rendering [html] <? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">