我在本地构建了静态Sphinx文档(使用make html).
我现在希望将Sphinx文件集成到我使用Flask运行的webapp中.在Flask运行应用程序中,我只是想包含一个指向Sphinx文档的超链接,它将作为应用程序的帮助.
Websupport似乎是要遵循的方式,但我不清楚如何将Flask框架与Sphinx文件联系起来.
谢谢你的帮助,
问候
我正在使用漂亮的sphinx-bootstrap-theme 0.3.4并尝试将其应用于Sphinx Python Documentation Generator 1.2版之上.
当我构建文档时make html,我没有得到任何侧边栏,虽然在这个例子中显示它是可能的.两者都没有,我能够在构建配置文件(conf.py)中找到任何启用侧栏的选项.执行以下操作:
html_sidebars = {'sidebar': ['localtoc.html', 'sourcelink.html', 'searchbox.html']}
Run Code Online (Sandbox Code Playgroud)
没有帮助.
感谢您提供有关如何通过这样的Sphinx主题启用侧边栏的任何提示.
这是一个关于使用的问题wtforms SelectField.
提交表单后,我希望提取所选文本.
我有以下表格:
from wtforms import Form, SelectField
class TestForm(Form):
hour = SelectField(u'Hour', choices=[('1', '8am'), ('2', '10am') ])
Run Code Online (Sandbox Code Playgroud)
这是观点:
@app.route('/', methods=['GET', 'POST'])
def test_create():
form =TestForm(request.form)
if request.method == 'POST' and form.validate():
test = Test()
form.populate_obj(test)
test.hour=form.hour.name
db.session.add(test)
db.session.commit()
return redirect(url_for('test_create'))
return render_template('test/edit.html', form=form)
Run Code Online (Sandbox Code Playgroud)
随着test.hour=form.hour.name我获得属性name(毫不奇怪......),同时我需要文本(假设8am选择了第一个选项).
这怎么可能?谢谢你的任何提示.
我将Flask-Admin与Flask-Login和mongoengine结合使用.
我希望根据用户自定义视图.以下can_create是允许模型创建的示例.
class MyModelView(ModelView):
column_exclude_list = ['password']
def is_accessible(self):
if (login.current_user.login != 'admin'):
can_create=False
return login.current_user.is_authenticated()
Run Code Online (Sandbox Code Playgroud)
这样的代码没有任何效果:所有用户仍然可以创建,管理员和非管理员用户之间没有区别.
非常感谢任何关于如何仅允许给定用户创建模型的提示.