【问题标题】:why is my django render function not returning correct output为什么我的 django 渲染函数没有返回正确的输出
【发布时间】:2017-12-05 15:24:50
【问题描述】:

我有一个具有以下参数的渲染函数。这给了我在定向页面上的正确输出。

return render(request, 'about_experiment.html', {'researcher': researcher})

但是当我包含另一个参数时,它不会为它做任何工作,因为研究输出没有到来

return render(request, 'about_experiment.html', {'researcher': researcher}, {'study': study})

我哪里错了

【问题讨论】:

  • 我明白了,谢谢。 return render(request, 'about_experiment.html', {'researcher': researcher, 'study': study})

标签: django python-2.7 django-models django-forms django-views


【解决方案1】:

试试这个,

return render(request, 'about_experiment.html', {'researcher': researcher, 'study': study})

因为django的渲染功能

render(request, template_name, context=None, content_type=None, status=None, using=None)

这里的上下文是dict。

【讨论】:

    猜你喜欢
    • 2018-10-28
    • 2015-03-21
    • 2012-09-07
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 2017-09-13
    相关资源
    最近更新 更多