Apache Web 服务器上的 Django ‘dict’对象没有属性“render_context”;
我遇到了一些问题,我将 Django 项目上传到运行 apache、mod_python 和 django 的网络服务器。在我开发的计算机上,以下工作正常
nameBox = getNamesBox().render(locals())
-
def getNamesBox():
users = User.objects.filter()
templateString = '<select name="name box">'
for user in users:
templateString += '<option value="' + user.name + '"> ' + user.name + '</option>'
templateString += '</select>'
template = Template(templateString)
return template
但在网络服务器上,当从 apache 或 manage.py runserver 运行时,它说
AttributeError at /order_site/order/
'dict' object has no attribute 'render_context'
The code on两台机器是相同的,所以我觉得可能是其他问题?它无法呈现我的表单,我不知道为什么。
I'm having a bit of a problem, I uploaded my Django project to a webserver running apache, mod_python, and django. On the computer I developed on the following works fine
nameBox = getNamesBox().render(locals())
-
def getNamesBox():
users = User.objects.filter()
templateString = '<select name="name box">'
for user in users:
templateString += '<option value="' + user.name + '"> ' + user.name + '</option>'
templateString += '</select>'
template = Template(templateString)
return template
But on the web server, when running from apache or manage.py runserver, it says
AttributeError at /order_site/order/
'dict' object has no attribute 'render_context'
The code on both machines is identical so I feel like maybe its some other issue? It can't render my form and I don't know why.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Template
上的render()
方法采用Context
对象作为其参数,而不是字典。您必须从字典构造一个 Context 对象,例如The
render()
method on aTemplate
takes aContext
object as its argument, not a dict. You'll have to construct aContext
object from the dict, e.g.