3 ms·
>All well and good; but what if you want to change the size, maxlength, or add a class ? Adding a class: Django gives every element of the form id values for e
by metamemetics 16y ago
>All well and good; but what if you want to change the size, maxlength, or add a class ?
Adding a class: Django gives every element of the form id values for easy styling in CSS. Just do {{form.as_p}} and see what it outputs.
size and max length: I'm fine with these in python as they correspond to the max-length that would be validated into a data member. If you mean pixel size on screen, this belongs neither in HTML or your template but in CSS, since browsers render forms completely differently regardless of their HTML attributes, you have to style their width\height in CSS to get anything consistent.
- erlanger 16y agoUnfortunately, the defaults stink. 1.2 remedies this for error messages at least. as_p and co. should include some class describing the field type in the outer <p> tag so that a developer can style the label and error messages in a way specific to the field type.