0

I have a form that stores a Field with a Textarea widget to a CharField, I would like for it to not clean out line breaks and other formatting information such as tabs and multiple spaces. Is there a way to go about doing this?

special_instructions = forms.CharField(
        label = "Special Instructions",
        widget=forms.Textarea(
            attrs={
                'id': 'textarea-ed95',
                'class':'u-border-1 u-border-grey-30 u-input u-input-rectangle',
                'placeholder':'Special Instructions'
            }
        )
    )
Cade
  • 41
  • 9
  • The `CharField` does not remove line breaks or multiple spaces. It is just how HTML works multiple spaces are rendered as one, if you search about this instead you would find many answers. :) – Abdul Aziz Barkat Apr 26 '21 at 07:40
  • @AbdulAzizBarkat could you please link to a question covering this topic and how i can get my strings to display properly, I am looking and not managing to find one. – Cade Apr 26 '21 at 11:44
  • Does this answer your question? [Render a string in HTML and preserve spaces and linebreaks](https://stackoverflow.com/questions/9492249/render-a-string-in-html-and-preserve-spaces-and-linebreaks) – Abdul Aziz Barkat Apr 26 '21 at 11:58

0 Answers0