﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27445	RadioSelect widget does not work for NullBooleanField	Anne Fleischer	David Smith	"The default widget for NullBooleanFields result in a selectbox with 3 options being shown.
In my opinion it should also be possible to represent those 3 options by radio inputs.
However, simply changing the form widget for a NullBooleanField to be a RadioSelect, will result in no form inputs whatsoever being shown.

Here is the code to reproduce it:

{{{
from django.db import models

class MyTestModel(models.Model):
    foo = models.NullBooleanField(blank=True, null=True)
}}}


{{{
from django import forms

class MyTestModelForm(forms.ModelForm):
    class Meta:
        model = MyTestModel
        fields = ('foo',)
        widgets = {
            'foo': forms.RadioSelect,
        }
}}}

I'm not sure if this is a bug or if the bahaviour is intentional.
As a workaround I tried to just initialize the choices manually in the widget, like this:

{{{
widgets = {
            'foo': forms.RadioSelect(choices=(('', 'Unknown'), ('1', 'Yes'), ('0', 'No'))),
        }
}}}

However, this works in terms of storing the correct value, but it does not render the selected radio input as checked.


I'd like to work in this if someone can confirm that this behaviour is not intended."	Cleanup/optimization	closed	Documentation	dev	Normal	fixed	NullBooleanField, RadioSelect		Ready for checkin	1	0	0	0	0	0
