你必须重写视图才能更改
_template_args。
class TestAdmin(ModelView): form_overrides = dict(text=forms.CustomtextareaField) create_template = 'edit.html' edit_template = 'edit.html' @expose('/edit/', methods=('GET', 'POST')) def edit_view(self): self._template_args['foo'] = 'bar' return super(TestAdmin, self).edit_view()如果要将某些全局值传递给模板,则可以使用
context_processor(http://flask.pocoo.org/docs/templating/#context-processors)。
@app.context_processordef inject_paths(): # you will be able to access {{ path1 }} and {{ path2 }} in templates return dict(path1='x', path2='y')


