html - Django form input weird behavior -
i trying generate django form , seems pretty straightforward.
<div class="form-group"> <label class="control-label col-sm-3 col-sm-3 col-xs-12" for="ad-interest"> ad interest </label> {{ form.ad_interest }} </div> it generated this:
however when try wrapping html around input closing > of input tag generated on page.
updated input tag:
<div class="form-group"> <label class="control-label col-sm-3 col-sm-3 col-xs-12" for="ad-interest"> ad interest </label> <div class="col-md-6 col-sm-6 col-xs-12"> <input type="text" class="form-control col-md-7 col-xs-12" id="ad-interest" value="{{ form.ad_interest }}" > </div> </div> generates this:
i dont understand why "extra" stuff showing on form. functionality isnt affected though
i bet form field ad_interest charfield, doing {{ form.ad_interest }}, django using default widget charfield, that's why without doing in first case you've got <input .....> html.
however, if wrap default widget layer of <input...>, html show above. essicially having following html, invalid:
<input type="text" class="..." value="<input...>" > you see default widget html using barely {{ form.ad_interest }} , also, field renders correctly, right? :)
see django doc widget textinput.


Comments
Post a Comment