0

Has anyone had any success incorporating MDBootstrap classes into their Django forms? I have MDBootstrap working fine in my Django project, but since I am having django render my form fields I can't figure out how I could use the MDBootstrap form component styling.

Essentially if I do this it comes up with the bootstrap styling:

<input type="text" id="textInput" class="form-control mb-4" placeholder="First Name">

But since I'm rendering my forms fields like this - I can't figure out how to achieve the same cosmetic result:

{{form.firstname}}
GXM100
  • 417
  • 6
  • 20

1 Answers1

0

You could try django-widget-tweaks, then it could be written as:

{{ form.firstname|add_class:"form-control mb-4"|attr:"type:text"|attr:"placeholder:First Name"}}

It creates an id, but you can also add your own as another attribute.

GCru
  • 426
  • 6
  • 8