擅长:python、mysql、java
<p>要将默认布尔值设置为True,需要将默认值设置为“checked”</p>
<blockquote>
<p>Basic fields Basic fields generally represent scalar data types with
single values, and refer to a single input from the form.</p>
<pre><code>class wtforms.fields.BooleanField(default field arguments, false_values=None)
</code></pre>
<p>Represents an input type="checkbox". Set the
checked-status by using the default-option. Any value for default,
e.g. default="checked" puts checked into the html-element and sets the
data to True</p>
</blockquote>
<p><a href="https://wtforms.readthedocs.io/en/stable/fields.html#wtforms.fields.BooleanField" rel="nofollow noreferrer">Source</a></p>
<pre><code>class QuestionForm(Form):
question = TextField('Question', [validators.Required()])
slug = TextField('Slug', [validators.Required()])
active = BooleanField('Active', default="checked")
</code></pre>