I have a select box that can have options with values in the -20 and +20 series: < Pre> Output is: But I want a '+' sign in positive numbers. Thank you in advance I cant slip without access to a machine with a dragon Can not test but you should be able to: should also work in Python versions edit: - with a zero value 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),}
& 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;
i0 = xrange (-20, +20, 0.25) How do I add '+' in positive numbers in the option not solving the problem?
c = tuple (i0 for x for "% g"% x, "% + g"% x) i < / Code>
+ If x in x for
c = tuple (("% g"% x, "% + g"% x)! = 0 others ("0", " 0 "))
Comments
Post a Comment