How to stop Django from adding extra html elements to rendered widgets.

Posted by stinkypyper on Stack Overflow See other posts from Stack Overflow or by stinkypyper
Published on 2010-05-17T18:39:19Z Indexed on 2010/05/17 18:40 UTC
Read the original article Hit count: 186

I have a Django radio button group that renders to HTML as follows:

<ul>
<li><label for="id_package_id_0"><input type="radio" id="id_package_id_0" value="1" name="package_id" /> Test 256</label></li>
<li><label for="id_package_id_1"><input type="radio" id="id_package_id_1" value="2" name="package_id" /> Test 384</label></li>
<li><label for="id_package_id_2"><input type="radio" id="id_package_id_2" value="3" name="package_id" /> Test 512</label></li>
<li><label for="id_package_id_3"><input type="radio" id="id_package_id_3" value="4" name="package_id" /> Test 768</label></li>
<li><label for="id_package_id_4"><input type="radio" id="id_package_id_4" value="5" name="package_id" /> Test 1024</label></li>
</ul>

I need it to render without being a list. I am a aware of form.as_p, form.as_table, and form.as_ul. They will not help me as they continue to add extra HTML tags. As well, I am not using the form object in it's absolute entirety, just for validation. I am doing a custom template for the form already, but wish to continue to the radio widget.

© Stack Overflow or respective owner

Related posts about django

Related posts about django-templates