嗨,我想知道如何在代码中的“输入”左侧添加字形,因为我使用的是 django,我必须使用 forms.py,你知道。
我的 HTML 代码:
<form methode="post" action="/connexion" class="form-horizontal" role="form">
{% csrf_token %}
{{ form.as_p }}
<div>
<button type="submit" class="btn btn-info"><span class="glyphicon glyphicon-off">Connexion</button>
</div>
</form>
形式.py:
class ConnexionForm(forms.Form):
user = forms.CharField(label='', max_length=30, widget=forms.TextInput(attrs={'placeholder': "Nom d'utilisateur"}))
password = forms.CharField(label='', widget=forms.PasswordInput)
您可以手动渲染字段而不是渲染整个表单,例如:
<form ...>
...
<i class="glyphicon..."></> {{ form.field_name }}
...
</form>
请参阅文档。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句