我有点问题,我把我的Django项目上传到一个运行apache、mod_python和Django的web服务器上。在电脑上我开发了以下的功能
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
但是在web服务器上,当从apache或manage.py runserver运行时,它说
AttributeError at /order_site/order/
'dict' object has no attribute 'render_context'
两台机器上的代码都是一样的,所以我觉得这可能是另一个问题?它不能呈现我的形式,我不知道为什么。
Template
上的render()
方法以一个Context
对象作为其参数,而不是dict。您必须从dict构造一个Context
对象,例如相关问题 更多 >
编程相关推荐