Why does my line have a colon added when output in HTML

When I add parathesis to the next line of the label, it prints in my HTML with a colon added:

question_3 = forms.MultipleChoiceField(choices=QUESTION_3_CHOICES,
widget=forms.CheckboxSelectMultiple(), label = mark_safe('Which of 
these styles do you like? (choose multiple)'))

A shortcut in my form is output as follows in my HTML:

 Which of these styles do you like? (choose multiple):

When I remove '(select multiple)', it prints correctly like this, without adding a colon:

Which of these styles do you like?

I tried converting all the text to unicode before using mark_safe by doing the following:

question_3 = forms.MultipleChoiceField(choices=QUESTION_3_CHOICES,
widget=forms.CheckboxSelectMultiple(), label = mark_safe('Which of 
these styles do you like? (choose multiple)').decode('unicode-escape'))

But this cannot be fixed ...

+3
source share
1 answer

If the question: "Why is this happening?" then look at the source of the BaseForm class (in django.forms.forms.BaseForm):

if self.label_suffix:
    if label[-1] not in ':?.!':
        label += self.label_suffix
label = bf.label_tag(label) or ''

By default, the BaseForm constructor sets label_suffix = ':'.

? label_suffix , , BaseForm.

+2

All Articles