Home>

We create web pages using Django.
If an error occurs during validation, we want to store the error message in a variable in advance and display it.

Currently, the display itself is fine, but when I display it, I want to display it with line breaks at sentence breaks.

FORMAT_STR = "This is an error message. Please try again."


When displaying something that looks like

This is an error message.
Please try again.


I want to display.

FORMAT_STR = "This is an error message. \ nPlease try again."


As I tried to insert a newline character, it was not a newline. I thought it was necessary to escape the newline character, and when I tried to change the newline character to "\\ n", "\ n" was displayed.
This FORAT_STR is passed as an argument to form.add_error (). In HTML, it is displayed as a Django system message (?).

{% if messages%}
<ul>
        {% for message in messages%}
        <li {% if message.tags%}
                {% endif%}>{{message}}</li>
        {% endfor%}
</ul>
{% endif%}


Isn't it possible to display a line break in this situation?