Adding styles to django.forms controls using Bootstrap -
i have form in html page generating using django's forms.form class. apply styles html controls generated using bootstrap. found bootstrap applies styles form controls if have class attribute e.g. form-control
. including form object in template using form.as_p
directive. since there no explicit html controls write in html page, don't know how include class attribute styles applied. can please help me solve problem can apply bootstrap styles form controls?
thanks, rakesh.
you can define widget. example:
class searchform(forms.form): q=forms.charfield(widget=forms.textinput(attrs={'class':'form-control', 'placeholder':'search'}))
another illustration using modelform
:
class searchform(modelform): class meta: model = searchfield fields = ['name'] widgets = { 'name' = forms.textinput(attrs={'class':'form-control'}) }
django twitter-bootstrap
No comments:
Post a Comment