'+' in django form -


I have a select box that can have options with values ​​in the -20 and +20 series: < Pre> class MyForm (forms.ModelForm): square meta: i0 = xrange (-20, 20, 0.25) c = tuple ("% g" for x in x0 x, "% g"% x) Model) = MyModel widgets = {'my_field': forms.Select (options = c),}

Output is:

  & lt; Select & gt; & Lt; Option value = "- 20" & gt; -20 & lt; / Options & gt; & Lt; Option value = "- 19.75" & gt; -19.75 & lt; / Options & gt; & Lt; Option value = "- 1.55" & gt; -19.5 & lt; / Options & gt; & Lt; Option value = "- 19.25" & gt; -19.25 & lt; / Options & gt; & Lt; Option value = "-19" & gt; -19 & lt; / Options & gt; . . . & Lt; Option value = "19" & gt; 19 & lt; / Options & gt; & Lt; / Select & gt;   

But I want a '+' sign in positive numbers. i0 = xrange (-20, +20, 0.25) How do I add '+' in positive numbers in the option not solving the problem?

Thank you in advance

I cant slip without access to a machine with a dragon Can not test but you should be able to:

  c = tuple (i0 for x for "% g"% x, "% + g"% x) i < / Code>  

should also work in Python versions

edit: - with a zero value + If x in x for c = tuple (("% g"% x, "% + g"% x)! = 0 others ("0", " 0 "))

Comments