Beno
Beno

Reputation: 576

Add a glyphicon even if i use Django

Hi I'd like to know how can i add a glyphicon to the left of "input" in my code because I'm using django and I have to use forms.py you know.

My HTML code :

<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>

forms.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)

Upvotes: 0

Views: 985

Answers (1)

Alex Mozharov
Alex Mozharov

Reputation: 456

You can just render fields manually instead of rendering the whole form, like:

<form ...>
    ...
    <i class="glyphicon..."></> {{ form.field_name }}
    ...
</form>

See the docs.

Upvotes: 1

Related Questions