Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以使用任何 python 字典作为上下文还是应该使用 django.template.Context 提供的字典?
它有什么区别?
TIA
您只需将 (python-) 字典插入 django 请求上下文,即可在模板中使用变量,例如:
def some_view(request): my_data_dictionary={...} return render_to_response('my_template.html', my_data_dictionary, context_instance=RequestContext(request))