Python 如何将引导所见即所得添加到烧瓶中?

Python 如何将引导所见即所得添加到烧瓶中?,python,bootstrap-wysiwyg,Python,Bootstrap Wysiwyg,我想在我的Flask网站上使用。 我找到了这个项目,并遵循了作者的建议,但它不起作用 我想知道: 怎么了 我该如何自己解决这个问题 代码如下: form.py from .wysiwyg import WysiwygField class PostForm(Form): article_title = StringField(u'title', validators=[Required(), Length(1, 64)]) body = WysiwygField(u"txt

我想在我的
Flask
网站上使用。 我找到了这个项目,并遵循了作者的建议,但它不起作用

我想知道:

  • 怎么了
  • 我该如何自己解决这个问题
代码如下:

form.py

from .wysiwyg import WysiwygField

class PostForm(Form):
    article_title = StringField(u'title', validators=[Required(), Length(1, 64)])
    body = WysiwygField(u"txteditor", validators=[Required()])
    submit = SubmitField(u'submit')
view.py

# views.py
from .forms import PostForm
@main.route('/post', methods=['GET', 'POST'])
@login_required
def post():
    title = u'edit'
    form = PostForm()
    if  form.validate_on_submit():
        posts = Post(article_title=form.article_title.data,
                     body=form.body.data,
                     author=current_user._get_current_object())
        db.session.add(posts)
        flash(u'commit')
        return redirect(url_for('.doc'))
    return render_template('post-rich-text-edit.html', title=title, form=form)
post-rich-text-edit.html

{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}

{% block head %}
{{ super() }}
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='prettify.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='font-awesome.css') }}">


    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
{% endblock %}

{% block page_content %}
<div class="page-header">
    <div class="row">
        <div class="col-md-12">
            <form method=post action="/">
            {{ form.article_title }}
                {{ form.hidden_tag() }}
                {{ form.body.label }}
                <div id="editor">
                {{ form.body(size=20) }}

                </div>
            {{ form.submit }}
            </form>
        </div>
    </div>
</div>
{% endblock %}

{% block scripts %}
{{ super() }}
    <script  type="text/javascript" src="{{ url_for('static', filename='bootstrap-wysiwyg.js') }}"></script>
    <script  type="text/javascript" src="{{ url_for('static', filename='jquery.hotkeys.js') }}"></script>
    <script  type="text/javascript" src="{{ url_for('static', filename='prettify.js') }}"></script>
{% endblock %}
{%extends“base.html”%}
{%import“bootstrap/wtf.html”作为wtf%}
{%block head%}
{{super()}}
{%endblock%}
{%block page_content%}
{{form.article_title}
{{form.hidden_tag()}}
{{form.body.label}
{{form.body(size=20)}
{{form.submit}
{%endblock%}
{%block scripts%}
{{super()}}
{%endblock%}

您所面临的问题还不是很清楚。但是,您有一个观点,即包的文档可能会产生误导

要使用所见即所得字段,请将
forms.py
中的
import语句更改为:

from flask_wysiwyg.wysiwyg import WysiwygField

脚本块
中的最后3行移动到
头块
所见即所得字段
添加到
表单.py

from flask_wysiwyg.wysiwyg import WysiwygField
并添加到
post-rich-text edit.html

<script>
    $('#editor').wysiwyg();
</script>

$(“#编辑器”).wysiwyg();

您看到的错误是什么?请包括完整的回溯。它不能在我的编辑器中编辑。有一个简单的,但不能写任何东西。@谢谢。而且它也不起作用。但不能编辑,不能写任何东西。@ Abirdcfly,请考虑通过点击复选标记来接受答案,如果它对你有帮助的话。