gpt4 book ai didi

django - 将多个对象传递给 Django 中的 RequestContext

转载 作者:行者123 更新时间:2023-12-04 22:06:59 26 4
gpt4 key购买 nike

我需要将字典和对象传递给模板。所以,我这样做

rc = RequestContext(request, {'prob':prob}, {'result':result})
return render_to_response('subject/question.html', context_instance=rc)

但我得到一个错误。
Traceback: File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs) File "E:\django-sample\proschools\..\proschools\subject\views.py" in eval_c
72. rc = RequestContext(request, {'prob':prob}, {'result':result}) File "C:\Python27\lib\site-packages\django\template\context.py" in __init__
173. self.update(processor(request))

Exception Type: TypeError at /practice/c/eval/
Exception Value: 'str' object is not callable

最佳答案

rc = RequestContext(request, {'prob':prob, 'result':result})

第三个参数是 processors那应该是元组或列表

关于django - 将多个对象传递给 Django 中的 RequestContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10361056/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com