【发布时间】:2011-11-25 15:05:30
【问题描述】:
我有这个表单域:
email = forms.EmailField(
required=True,
max_length=100,
)
它具有 required 属性,但在 html 中它没有添加 html 属性required。事实上,它甚至没有使用 email 作为字段类型,它使用的是 text... 虽然它似乎得到了 max_length 就好了。
实际:
<input id="id_email" type="text" name="email" maxlength="100">
预期:
<input id="id_email" type="email" name="email" maxlength="100" required="true">
如何让 Django 在 html 表单中使用正确的属性?
【问题讨论】: