[Solved] Customizing Radio buttons in Django [duplicate]


you should do like this, hope this will work for you.

from django import forms

TEST_TYPE_CHOICES = [
('HDFS', 'HDFS'),
('HIVE', 'HIVE'),
('BOTH', 'Both of HDFS and HIVE'),]

class TestForm(forms.Form):
    # hdfs_test = forms.MultipleChoiceField()
    # hive_test = forms.MultipleChoiceField()
    # hdfs_hive_test = forms.MultipleChoiceField()
    test_type = forms.MultipleChoiceField(required=True, widget=forms.RadioSelect(), choices=TEST_TYPE_CHOICES)
    event_textarea = forms.Textarea(attrs={'rows': '8', 'class': 'form-control', 'placeholder': 'Events...', 'id': 'event_textarea'})
    def __init__(self, *args, **kwargs):
        super(metaForm, self).__init__(*args, **kwargs)
        field.widget.attrs['test_type'] = 'your class name here'

Or you should also do like this :

from django import forms
TEST_TYPE_CHOICES = [
('HDFS', 'HDFS'),
('HIVE', 'HIVE'),
('BOTH', 'Both of HDFS and HIVE'),]

class TestForm(forms.Form):
    # hdfs_test = forms.MultipleChoiceField()
    # hive_test = forms.MultipleChoiceField()
    # hdfs_hive_test = forms.MultipleChoiceField()
    test_type = forms.MultipleChoiceField(required=True, widget=forms.RadioSelect(attrs={'class':'your class name here'}), choices=TEST_TYPE_CHOICES)
    event_textarea = forms.Textarea(attrs={'rows': '8', 'class': 'form-control', 'placeholder': 'Events...', 'id': 'event_textarea'})

solved Customizing Radio buttons in Django [duplicate]