Home > Blockchain >  String with white space being passed incorrectly in a Django template
String with white space being passed incorrectly in a Django template

Time:12-21

I have a variable called "Vintage White" that I am trying to pass to an attribute of an input element like so.

<input name={{ attribute_value }}>

What I expect is for the element to be rendered like this

<input name="Vintage White">

But instead I get this

<input name="Vintage" white>

How do I pass the entire string with white spaces to the input element so that I get my expected result?

CodePudding user response:

You need to use quotation marks, otherwise the value will end before the first space of the attribute_value, so:

<input name="{{ attribute_value }}">
  • Related