1

How to remove label from MultipleChoiceField in template?

enter image description here

forms.py:

class RequirementAddForm(forms.ModelForm):
    symbol = forms.MultipleChoiceField(required=False, widget=forms.CheckboxSelectMultiple, choices=REQUIREMENTS_CHOICES,)

    class Meta:
        model = Requirement
        fields = ('symbol',)

template.html:

{{ form }}
Nurzhan Nogerbek
  • 4,806
  • 16
  • 87
  • 193

1 Answers1

2

Here are some possible solutions

1) Use label="" when inside your form definition

2) Override the label, if you are using an inherited form and don't have direct access

def __init__(self, *args, **kwargs):
    super(FormClass, self).__init__(*args, **kwargs)
    self.fields['field'].label = ''

Another possible option is to pass auto_id=False into the form

NS0
  • 6,016
  • 1
  • 15
  • 14
  • Thanks! In the beginning I used `self.fields['symbol'].label = None` but it didnt work. Then after your answer I use `self.fields['field'].label = ''` and it works for me. – Nurzhan Nogerbek Apr 24 '17 at 16:41