Context的本质就是一组用字典封装好的准备送给template的参数,在view和template中扮演桥梁的角色。
作为面向对象的程序,传递的参数不仅仅是简单的变量还可以是class等,
>>> # Create a class with a single method
>>> class Favorite():
>>> def get_color(self):
>>> return 'blue'
>>>
>>> favorite = Favorite()
>>> c = Context({'favorite': favorite })
>>> t = Template('My favorite color is {
{ favorite.get_color }}.')
>>> print t.render(c)
My favorite color is blue.
>>> color_list = ['orange', 'blue&#