Django TextField and CharField is stripping spaces and blank lines

后端 未结 5 1262
[愿得一人]
[愿得一人] 2021-01-07 23:39

I just researched my \"bug\" and it turned out to be a new feature in Django 1.9 that CharFields strip spaces by default : https://docs.djangoproject.com/en/1.9/ref/forms/fi

5条回答
  •  失恋的感觉
    2021-01-08 00:32

    strip=False 
    

    in the model field for CharFields.


    Django TextField do not support this stripping feature so you have to do it on your own. You can use the strip method.

    abc.strip()
    

提交回复
热议问题