'Django customize Label of form

whenever I add a Labels to ModelForm, the Label will look in the HTML like this:

                      #v check this colon
<label for="id_url">URL:</label>

When I created the labels like this:

class FieldForm(forms.ModelForm):
    class Meta:
        model = Field

        fields = (
            'title',
            'url',
        )

        labels = {
            'title': 'Title',
            'url': 'URL'

Where do the colons at the end of the Label in the HTML come from and how to remove them?



Solution 1:[1]

I haven't tried it, but found answer here: Django form. How hide colon from initial_text?

class FieldForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.label_suffix = ""  # Removes : as label suffix

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NixonSparrow