views:

114

answers:

3

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.

A: 

Check out Django 1.2 (released today), which includes build in Model Validation.

Then just write out your forms by hand :)

Bryan Ross
A: 

To render just that one field of your form, you need to output your field in the template with something like this:

{{ form.my_radiofield }}

That will output just the one widget without any extra table, p or ul markup. You can read more about that here.

Jason Webb
I am actually already doing that. The problem is that is outputs the widget itself formatted.
stinkypyper
Then I am not sure what you are asking. If not markup, what do you mean by formatted?
Jason Webb
A: 

I guess you will have to subclass the necessary widgets and overwrite their render()-method!

lazerscience