开发者

Django on Apache web server 'dict' object has no attribute 'render_context'

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.


The render() method on a Template takes a Context object as its argument, not a dict. You'll have to construct a Context object from the dict, e.g.

namedbox = getNamesBox().render(Context(locals()))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜