Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django template: string automatically got truncated by white space in input value

I'm trying to set the initial value of a input field. In the template, I have

<input id="title" name="title" value={{ post_title }}>

where post_title is a string. The weird thing is, if there is a whitespace in post_title, it would be split and only the part before the whitespace would be displayed. For example, if post_title = "hello world", the rendered html is

<input id="title" name="title" value="hello" world>

Everything is ok without whitespaces in post_title. I'm using Django 1.3.1 and python 2.6.

like image 275
blurrcat Avatar asked Sep 13 '25 17:09

blurrcat


1 Answers

Django's template engine won't fix broken HTML.

<input id="title" name="title" value="{{ post_title }}">
like image 200
Ignacio Vazquez-Abrams Avatar answered Sep 17 '25 19:09

Ignacio Vazquez-Abrams