Joh*_*acs 6 html python apache django mod-python
我遇到了一些问题,我将我的Django项目上传到运行apache,mod_python和django的网络服务器.在我开发的计算机上,下面的工作很好
nameBox = getNamesBox().render(locals())
Run Code Online (Sandbox Code Playgroud)
-
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
Run Code Online (Sandbox Code Playgroud)
但是在Web服务器上,当从apache或manage.py runserver运行时,它说
AttributeError at /order_site/order/
'dict' object has no attribute 'render_context'
Run Code Online (Sandbox Code Playgroud)
两台机器上的代码是相同的,所以我觉得可能是其他一些问题?它不能渲染我的形式,我不知道为什么.
Raf*_*ler 15
a上的render()方法Template以Context对象为参数,而不是dict.你必须Context从dict 构造一个对象,例如
namedbox = getNamesBox().render(Context(locals()))
Run Code Online (Sandbox Code Playgroud)