Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blank label_suffix across entire Django project

I'd like to eliminate the colon (:) that is automatically added to form labels across my entire Django project. I'd like to avoid adding label_suffix='' to every form in the project.

Is there a simple way to override it everywhere?

like image 522
Brenden Avatar asked Jul 24 '12 00:07

Brenden


1 Answers

It would probably be best to extend Django's Form class, override the default, and extend all of your forms from it, like so:

from django import forms

class MySiteForm(forms.Form):
    def __init__(self, *args, **kwargs):
        kwargs.setdefault('label_suffix', '')
        super(MySiteForm, self).__init__(*args, **kwargs)

...

class RegistrationForm(MySiteForm):
    username = forms.CharField(max_length=255)
    ...
like image 100
Chris Forrette Avatar answered Nov 09 '22 15:11

Chris Forrette