djangoformslabeldjango-crispy-forms

Remove Labels in a Django Crispy Forms


Does anybody know if there is a correct way to remove labels in a crispy form?

I got as far as this:

self.fields['field'].label = ""

But it's not a very nice solution.


Solution

  • 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