I created a Python script that retrieves a list of payments that go to my companies email. I thought it would be interesting to do for Cashapp/Venmo payments to compile them. However I really want the site to format the payments/details so that each payment is on a new line. In the python I put final = final + ..... + \n for the string that is to be used in the html. Yet \n
will not work in HTML no matter what I try to do.
In my views.py I set data=final, then call it here in the HTML.
<body>
<button onclick="location.href='{% url 'script' %}'" >
Check new payments
</button> <hr>
{% if data %}
{{data}}
{% endif %}
</body>
This prints out all the necessary data yet it is in one continuous string and does not include the \n. If I print it in the terminal it includes these. It is likely because html does not recognize \n I assume, I just don't know an alternative for this.
` etc depending on what you want to accomplish.
– ` tags. There are options like `tripleee Feb 03 '22 at 10:31` in formatted HTML. Note, the Django template engine will escape `<>` unless it's safe'd `{{data|safe}` or is substituting a safe string ( generated with `format_html`, `mark_safe`, etc.) – nigel222 Feb 03 '22 at 10:39