Allowing single values instead of tuples for choices in ChoiceField
|Reported by:||Filip Gruszczyński||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
At the moment, when I want set choices for a ChoiceField, I have to put a list of tuples. In some situations this is inconvenient, e.g. when I have list of values that I just want to use. For example I have to do it like this:
choices = ['A', 'B', 'C'] choice_field = ChoiceField(choices=zip(choices, choices))
It would be eaiser if I could just do it like this:
choice_field = ChoiceField(choices=['A', 'B', 'C'])
And even more, like this:
choice_field = ChoiceField(choices=['A', 'B', ('C', 'c')])
And all of this would create choices lists with tuples, e.g. the last one would look like this: [('A', 'A'), ('B', 'B'), ('C', 'c')].
I am adding a patch, that does it.