[Answer]-Django form field data lost when using custom widget

1👍

The input’s name in the markup is wrong, so the form doesn’t collect it. Instead of

 <input id="user_{name}_{label}" name="user[{name}]" type="radio" value="{choice}">

you’d need

 <input id="user_{name}_{label}" name="{name}" type="radio" value="{choice}">

Also the standard scheme for controls id in Django forms is id_<name>[_counter]

Now Django already has a RadioSelect widget that gives you the same feature, so you’d be better using it (with your own specific markup in the template) instead of reinventing the (squared) wheel and hard-coding project’s specific template in your widget.

Leave a comment