2017-11-21 6 views
0

こんにちは私はdjangoを使っているので私はあなたの知っているform.pyを使用しなければならないので、 。 もし私がDjangoを使用していてもグリフコンを追加してください

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

forms.py:

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

を参照してください:あなただけのフィールドをレンダリングし、手動で代わりのように、フォーム全体をレンダリングすることができます

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) 
+1

[crispy forms](http://django-crispy-forms.readthedocs.io/ja/latest/)を使用してください。 –

+1

https://simpleisbetterthancomplex.com/article/2017/08/19/how-to-render-django-form-manually.html –

+0

@brunodesthuilliersありがとうございますが、どうすればグリフィンを追加できますか? – Beno

答えて

1

docs

+0

Mmh .. Intersting!私はそれが私の問題を解決すると思う!私はそれを試してみよう! Thaaaaanks – Beno

関連する問題