我生成的表单有此输入字段,默认长度为254。
<input id="id_email" maxlength="254" name="email" type="email">
由这个Django代码生成:
<div class="form-group">
<!-- Render the field label tag -->
{{ field.label_tag }}
<!-- If the field is required, display a * next to the field label -->
{% if field.field.required %}
{% endif %}<!-- Render the input field -->
{{ field }}<!-- Iterate over the field's errors, if any and display them one by one in a error alert-->
{% if field.errors %}
<p class="error">
{% for error in field.errors %}
{{ error }}
{% endfor %}
</p>
{% endif %}
如何摆脱长度限制?
答案 0 :(得分:1)
您必须更改max_length
课程中EmailField
的{{1}}参数:
Form
但是,由于您的数据库可能需要字段的长度规范,因此您将无法指定无限长度。