Django Forms Template design classes

前端 未结 4 1235
遇见更好的自我
遇见更好的自我 2021-01-06 08:23

Django Forms framework is excellent and renders the entire form by just the following.

{{ form.as_p }}

For a registration form, it converts

4条回答
  •  爱一瞬间的悲伤
    2021-01-06 08:59

    If you just need all labels to have a particular class, the best way would be to change the markup and CSS slightly. Put a

    with your class around the form:

    {{ form.as_p }}

    and make the CSS definition as follows:

    div.field-title label {
        ...
    }
    

提交回复
热议问题