Code

Ticket #4237: radio_select.diff

File radio_select.diff, 843 bytes (added by Robert Myers <myer0052@…>, 7 years ago)

use RadioSelect widget if radio_admin=True

Line 
1Index: django/db/models/fields/__init__.py
2===================================================================
3--- django/db/models/fields/__init__.py (revision 5156)
4+++ django/db/models/fields/__init__.py (working copy)
5@@ -345,7 +345,10 @@
6         "Returns a django.newforms.Field instance for this database Field."
7         defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text}
8         if self.choices:
9-            defaults['widget'] = forms.Select(choices=self.get_choices())
10+            if self.radio_admin:
11+                defaults['widget'] = forms.RadioSelect(choices=self.get_choices_default())
12+            else:
13+                defaults['widget'] = forms.Select(choices=self.get_choices_default())
14         defaults.update(kwargs)
15         return form_class(**defaults)
16