Django 1.11 TypeError context must be a dict rather than Context
1  | def current_datetime(request):  | 
在Django 1.11.11版本中运行会出现“TypeError context must be a dict rather than Context”的错误信息。

查阅 Stack Overflow 得知原因:
在Django 1.8+中,模板的render方法需要传入一个参数为字典的上下文实例,即ctx({key: value})。在Django 1.10+中,render方法传递一个Context实例已被弃用。
因此上述代码在Django 1.11中应改为:
1  | t.render({'current_date': now}) #get_template.render() 直接传入字典  | 
如果仍想以传入Context实例的方式渲染模版,可以使用下面的方法:
1  | from django.template.loader import render_to_string  | 
补充:
其实,Django为渲染模板提供了更为简单的方式:
1  | from django.shortcuts import render  | 
Django 1.11 TypeError context must be a dict rather than Context
https://oxo.red/Django_1.11_TypeError_context_must_be_a_dict_rather_than_Context/