各种有用的flask视图、蓝图、jinja2模板过滤器和模板/宏

flask_extras的Python项目详细描述


[![科达西徽章](https://api.codacy.com/project/badge/grade/1f8f45e92a9b4ed1ab5029ee7a0e5534)(https://www.codacy.com/app/dxdstudio/flask_extras?utm_source=github.com&utm_medium=referration&utm_content=christabor/flask_extras&utm_campaign=badger)
[![构建状态](https://travis-ci.org/christabro/flask_extras.svg?branch=master)(https://travis ci.org/christabor/flask_extras)
[![审查员代码质量](https://scrunizer-ci.com/g/christabor/flask_extras/badges/quality-score.png?b=master)](https://scrunizer-ci.com/g/christabor/flask_extras/?分支=主)
[![代码气候](https://codecoltime.com/github/christabor/flask_extras/badges/gpa.svg)](https://codecoltime.com/github/christabor/flask_extras)
[![覆盖状态](https://coveralls.io/repos/github/christabro/flask_extras/badge.svg?branch=master)“(https://coveralls.io/github/christabor/flask_extras?分支=主)
[![代码运行状况](https://landscape.io/github/christabro/flask_extras/master/landscape.svg?style=flat](https://landscape.io/github/christabro/flask廑extras/master)


flask extras
各种有用的烧瓶视图、蓝图、Jinja2模板过滤器和模板/宏。

过滤器和模板将通过以下简单命令自动注册和可用:

``python
from flask extras import flaskextras
app=flask('myapp')
flaskextras(app)
```

查看[此页](wiki/old_u setup.md)


有关所需的名称和位置,请参见每个视图。

*注意:*每个视图都有配置帮助程序来插入或配置应用程序。有关详细信息,请参见源代码。


\您可以像这样使用它们:

``html
{%来自'macros.html'导入列表组,objects2table%}
````

>对于最全面的文档,请查看每个[宏](flask_extras/macros/)。注释“docstrings”使用jinja2注释内联(这些注释不会在html中呈现)。

另外,检查源和/或输出以查看哪些类可用于样式重写。

用法:

`` python
app=status.inject_error_views(app)
```


有关详细信息,请参阅源代码。

用法示例:

`` python
`` python
`` python
from flask-extras.decorcordecordecordecordecorderheader
@require-header(['x-foo'])
def foo():
pass
``

























wtform扩展,用于将任意数量的单独表单作为单个、多个步骤进行处理,多岗位向导。所有状态和数据都由应用程序的会话后端处理。构建表单就像你习惯的那样——简单而直观。只需继承“multistepwizard”类并在其上放置一个“forms”键,这只是您要使用的所有表单的列表。*注意*:列出表单步骤的顺序。


用法示例:

``python
from flask.ext.wtf import flask form


from flask extras.forms.wizard import multistepwizard


Class multistepTest1(flaskform):
field1=stringfield(验证器=[validators.dataRequired()],)
field2=integerfield(验证器=[validators.dataRequired(),)



class multistepTest2(flaskform):
field3=stringfield(验证器=[validators.dataRequired(),)
field4=integerfield(验证器=[validators.dataRequired()],)


class mycolform(多步骤向导):
ute:

`` python
从表单导入mycolform

@app.route('/',methods=['get','post'])
dedeindex():
curr-graps=request.args.get('curr-curr-步骤')
form-kwargs=dict(session-key'mycuscustomkey')
curr-step不为none时:
form-kwargs.update(curr-step=curr-step=curr-step)
form=forms.mycolformformformformforms.mycoolform(**form-kwargs)
kwargs=dict(form=form)
request.method='post''post':br/>/grargs=dict(post=pos>如果form.validate_on_submit():
如果form.is_complete():
data=form.alldata(combine_fields=true,flush_after=true)
flash('form validated and complete!data={}。format(data),
“success”)
返回jsonify(data)
否则:
flash('很好,但还没有完成({}步骤仍然存在!)“.format(form.remaining))
否则:
flash('invalid form data.','error')
返回呈现模板('index.html',**kwargs)
````

>和一个示例html页面(使用[wtform.]表单(flask./u extras/macros/macros.html)宏):

``html
{%如果form.is\u complete()%}
<;跨距 class="well">Complete!</span>
{%else%}
<;ul class="list-inline">
{%用于表单中的步骤}
<;li>;
{%if step==form.curr\u step%}
<;强 class="lead label label-info">current {{ step }}</strong>
{%else%}
<;a ref={{{url}('app.index')}?当前步骤={{step}“>;{{step}<;/a>;
{%endif%}
{%if not loop.last%}
&;nbsp;/
{%endif%}
<;/li>;
{%endfor%}
<;/ul>;
{{wtform表单(表单,
classes=['form','form horizontal'],
btn_classes=['btn btn primary','btn lg'],
align='right',
action=url_for('app.index'),
method='post',
reset_btn=false,
horizontal=true,
)}
{%endif%}
```

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
安卓 Java LibGDX对内存使用感到困惑   使用@Generated的java自动增量   对名称java:comp/env/jdbc/bar进行间接查找时发生WebSphere NameNotFoundException   Java 8 lambda风格的JDBC语句执行包装器   java如何实现PushCacheFilter   java如何停止和启动jms侦听器   java确定数组中特定元素的总和   JavaJSF:如何使用selectOneRadio立即更新支持bean?   java Exo播放器活动   使类受保护时发生java错误   spring获得java。lang.IllegalArgumentException:只有SSLv3在com中启用。国际商用机器公司jsse2。disableSSLv3设置为TRUE   在java中打印垂直直方图时出现格式错误   Selenium Java处理不同语言和位置以及设置动态体系结构的最佳实践?   java实用程序方法传递文件或字符串?