0

我以前用 jinja 引擎使用过变形,但是用变色龙我无法渲染我的表单我将表单传递给要渲染的视图

 @view_config(route_name='home_cms',
             renderer='../views/accounts.pt',
             request_method='GET',
             )
def home(self):
    model = Bundle("ModelAccounts", xx.account_id,
                   xx.name, xx.state, xx.account_type)
    cm_filters = xxx(self.request.db)
    list_accounts = xxx.search(model=model)       
    return dict(list_accounts=list_accounts, filter_form=self.form.render())

在视图中我添加了这一行

 <span tal:content="python:filter_form"></span>

在主函数中我添加了这行代码

deform.renderer.configure_zpt_renderer()
config.add_static_view('static_deform', 'deform:static')
4

1 回答 1

1

您没有具体说明您得到了什么,但据我所知,我认为您面临的问题是您的 HTML 表单正在转义。如果是这种情况,请将 ../views/accounts.pt' 中的模板代码更改为:

<span tal:content="structure: filter_form"></span>

“结构”关键字告诉变色龙不要转义该值。有关详细信息,请参阅http://chameleon.readthedocs.io/en/latest/reference.html#structure

于 2017-03-21T18:56:27.663 回答