I created a web application and I am using the django-generated admin to insert some data. In particular, I have the following field:
description = models.TextField(max_length=10000, null=True, blank=True)
In the admin, it appears as a text area, where I can insert new empty lines. However when I insert something like
Some text followed by a new emtpy line.
Some other text.
the result I obtain in my HTML page invoking the REST API is something like this:
Some text followed by a new emtpy line. Some other text.
So, some spaces appear in place of the new line. If I drop the empty line and just insert a line break, the empty spaces reduce in numbers.
The REST API accessing that field is returning this:
Some text followed by a new emtpy line.\r\n\r\nSome other text.
How do I preserve the empty lines, given the description is correctly stored into the database?
The problem can be solved by adding a css directive for the text container:
white-space: pre-line;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With