[英]For flask how can I set the value for a custom input, but not get placeholder?
对于我的烧瓶和引导程序登录,当我设置值时,它会将占位符更改为<input id=
和一个随机密码。 此外,按钮文本包括 <"。
应用程序.py:
class LoginForm(FlaskForm):
username = StringField(validators=[InputRequired(), Length(
min=4, max=20)], render_kw={"placeholder": "Username"})
password = PasswordField (validators=[InputRequired(), Length(
min=4, max=20)], render_kw={"placeholder": "Password"})
@app.route('/login/', methods=['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first()
if user:
if bycrypt.check_password_hash(user.password, form.password.data):
login_user(user)
print('Logged in')
return redirect(url_for('sucess'))
return render_template('login.html', form=form)
登录.html
<form method="POST">
{{ form.hidden_tag() }}
<h1 class="h3 mb-3 fw-normal text-center text-white">Please sign in</h1>
<div class="form-floating">
<input class="form-control" placeholder="name@example.com" value="{{form.username}}">
<label for="floatingInput">Email address</label>
</div>
<br>
<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="Password" value="{{form.password}}">
<label for="floatingPassword">Password</label>
</div>
<br>
<button class="w-100 btn btn-lg btn-warning" type="submit" value="{{form.submit}}">Sign in</button>
<p class="mt-5 mb-3 text-muted">© 2017–2021</p>
</form>
尝试将“ type='text' ”添加到电子邮件输入中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.