Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide a django label in a custom django form?

I have a custom form that creates a hidden input of a field:

class MPForm( forms.ModelForm ):
    def __init__( self, *args, **kwargs ):
        super(MPForm, self).__init__( *args, **kwargs )
        self.fields['mp_e'].label = "" #the trick :)

class Meta:
    model = MeasurementPoint
    widgets = { 'mp_e': forms.HiddenInput()  }
    exclude = ('mp_order') 

I have to do this little trick to "hide" the label, but what I want to do is remove it from the form. I create the form like this:

forms.MPForm()
like image 661
Harchet Avatar asked Sep 26 '12 08:09

Harchet


Video Answer


1 Answers

Now,(my django version is 2.1.4), you can solve in this way -> Edit forms.py file:

password = forms.CharField(label=False)
like image 157
ZDL-so Avatar answered Oct 05 '22 11:10

ZDL-so