So form.as_p
in django gives a plain, yet very catered form, with field inputs matching the entity attribute type, like so:
Notice how vintage
is a dropdown item, and so is brand
. But then again, it's very plain.
I want to use bootstrap styling with the django form without losing the way django customizes each input type by the model attributes.
I have managed to achieve this:
By doing this in my .pug
template:
form(method="post" action=".")
| {% csrf_token %}
for field in da_form
div(class="form-group row")
label(class="col-lg-4 col-md-3 cold-sm-6 col-form-label") {{field.label_tag}}
div(class="col-lg-8 col-md-3 cold-sm-6")
input(class="form-control") {{field}}
input(class="form-control")(type="submit" value="submit")
But how can I both get the style, and the catered form inputs from django? In my current form all fields are simple input types.
form-control
to class, etc...) but without losing the custom input type for fields (notice how vintage is a dropdown item, and so is brand) – zerohedge