views:

153

answers:

1

I'd like to combine 6 variables that are of different types in my view...I thought the concatenation '+' will work but I get an error when I use it. I'd like the end result to be like this:

var1 var2 var3 var4 (var5 var6)

How do I go about this?

A: 

I'm assuming the problem you had with using + is that not all of the variables are strings. Use the following but replace %s with an applicable formatter from this list.

output_string = "%s %s %s %s (%s %s)" % (var1, var2, var3, var4, var5, var6)

Another option is to pass them to your template and output them there:

{{ var1 }} {{ var2 }} {{ var3 }} {{ var4 }} ({{ var5 }} {{ var6 }})
lemonad
I'd just gotten the same solution to work...seems I freaked out before I thought out everything straight. Thnx lemonad
Stephen