我正在尝试在引导程序弹出窗口中使用表单。一些基本的 html 工作(文本样式、按钮),但表单没有。(既不做 onclick() javascript 动作)
我尝试了几种选择,但在网上找不到任何解决方案。
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<button type="button" class="btn btn-lg btn-danger" data-toggle="popover" data-html='true' data-content="
<h3>This works</h3>
<form>
This does not:<br>
<input type='text' name='firstname'><br>
Last name:<br>
<input type='text' name='lastname'>
</form>
">popover with html form</button>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" …
Run Code Online (Sandbox Code Playgroud) 成功连接两个数据库表后,我尝试通过寻址第一个表来读取第二个表中的数据。opinion.topic_name
我从 jinja2 模板中寻址,但没有返回任何内容。如何从连接的查询中访问 Topic.topic_name 值?
@main.route('/', methods=['GET', 'POST'])
def index():
form = IndexForm()
opinions = []
if form.validate_on_submit():
opinions = Opinion.query
.filter_by(party_id=form.party.data)
.filter_by(topic_id=form.topic.data)
.join('topic')
.all()
return render_template('index.html', form=form, opinions=opinions)
Run Code Online (Sandbox Code Playgroud)
class Opinion(db.Model):
id = db.Column(db.Integer, primary_key=True)
text = db.Column(db.String(2000))
topic_id = db.Column(db.Integer, db.ForeignKey('topic.id'))
party_id = db.Column(db.Integer, db.ForeignKey('party.id'))
class Topic(db.Model):
id = db.Column(db.Integer, primary_key=True)
topic_name = db.Column(db.String(64))
opinions = db.relationship(Opinion, backref='topic')
Run Code Online (Sandbox Code Playgroud)
<div>
{{ wtf.quick_form(form) }}
</div>
<div>
{% for opinion in opinions %}
<div class='jumbotron'>
<h1>{{ opinion.topic_name …
Run Code Online (Sandbox Code Playgroud)