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:

ad-interest

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:

new ad-interest

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

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -