Django Context TypeError:上下文必须是字典而不是Context

时间:2018-12-14 16:36:51

标签: django

template = loader.get_template('organizer/tag_list.html')
context = Context( { 'tag_list': Tag.objects.all() } )
template.render(context)

在终端上运行这些操作会产生以下错误:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/noitanec/noitanec/django/django/lib/python3.6/site-packages/django/template/backends/django.py", line 59, in render
    context = make_context(context, request, autoescape=self.backend.engine.autoescape)
  File "/home/noitanec/noitanec/django/django/lib/python3.6/site-packages/django/template/context.py", line 270, in make_context
    raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than Context.

这是怎么了?

0 个答案:

没有答案