【发布时间】:2021-10-26 17:23:21
【问题描述】:
我知道有人问过这个问题here。
但是 anwser 不太适合我的需要。
在我的 Django 项目中,我想将上下文数据作为字典提供给我的模板。
像平常一样:return render(request, 'the.html', context)
我首先在没有任何 ajax 的情况下构建了我的整个网站,因此在成功时使用 ajax HTML 完全重写将是相当多的工作:
$("#div_to_update").html( -- completely rewrite already written html code to fit the new ajax -- )
有没有办法更轻松地将上下文传递给 django 模板之类的?
$("#div_to_update").set_context(context_the_server_passed_to_ajax)
【问题讨论】: