ログイン/サインアップページを生成するために django.forms を使用しています。コードの一部は次のとおりです。
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<table>
<tr>
{# username is directed to email field in our model #}
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="submit" value="login" />
{% if next %}
<input type="hidden" name="next" value="{{ next }}" />
{% else %}
<input type="hidden" name="next" value="{% url 'home' %}" />
{% endif %}
</form>
ご覧のとおり、 and はそれぞれ{{ form.username }}
と{{ form.password }}
を自動的に生成します。しかし、これらのフィールドに や などの追加の属性を追加したいと考えています。これらはどこでカスタマイズできますか?<input id="id_username" maxlength="254" name="username" type="text">
<input id="id_password" name="password" type="password">
input
placeholder
class