Newline in label for Django form field

后端 未结 2 1380
礼貌的吻别
礼貌的吻别 2021-02-14 02:35

Is there a way to put a newline in the label of a form field in Django? Putting a \\n just results in a newline in the HTML, and trying
just

2条回答
  •  甜味超标
    2021-02-14 03:08

    You can also do this directly in the template as follows:

     {{my_field.label|linebreaks}} 
    

    \n will convert to
    that way

    As per the doc,

    a single newline becomes an HTML line break (
    ) and a new line followed by a blank line becomes a paragraph break (

    ).

提交回复
热议问题