Remove Labels in a Django Crispy Forms
Just do:
self.helper.form_show_labels = False
To remove all labels.
Works with Boostrap ( see documentation )
In your form :
from crispy_forms.helper import FormHelperfrom django import formsclass MyForm(forms.Form): [...] def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_show_labels = False
In your template:
<form method='POST' action=''>{% csrf_token %}{% crispy form %}<input type='submit' value='Submit' class='btn btn-default'></form>
You could edit the field.html
template:https://github.com/maraujop/django-crispy-forms/blob/dev/crispy_forms/templates/bootstrap/field.html#L7
Add a FormHelper
attribute to your form that controls the label rendering and use it in that template if
. Custom FormHelper
attributes are not yet officially documented, because I haven't had time, but I talked about them in a keynote I gave, here are the slides:https://speakerdeck.com/u/maraujop/p/django-crispy-forms