I am making a very basic BBS system (like blog) in Django.
I've made a form where user can type in their content which I call 'body' and I declare it as folowing in the forms.py:
body = forms.CharField(widget= forms.Textarea, label="body",required=True)
and in the models.py,
body = models.TextField()
I somehow can't seem to be able to write multi line texts...
To sum it up,
I can write multiple lines into my form like:
Hello this is test
This is sample test2
333333
But When I submit it, I only see
Hello this is test This is sample test2 333333
The error happened when display it.
Textarea uses cr\lf
to break lines. That is how it would
be saved into db. But html will ignore cr\lf
you need to replace cr\lf
with <br>
or <p>
A template tag linebreaks can help you, when you display it.
{{ value|linebreaks }}
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