I prefer to store the actual value in database in many cases instead of an
assigned numerical or other representation so I find myself doing this:

color_choices = [(c,c) for c in ["red", "blue", "green"]]

It's not a difficult work-around but I would love to see Django accept a 1
dimensional list of values for choices as an alternative to a set of tuples.

Justin

On 10/31/07, ludvig.ericson <[EMAIL PROTECTED]> wrote:
>
>
> On Oct 30, 6:26 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> > It's always bugged me a little that choice lookups are based on the raw
> value.
> Agreed, but bloating the API doesn't solve that.
>
> Oh and a tip:
>
>     FOO_CHOICES = enumerate(("foo", "bar"))
>
> Throw on a tuple() if you want to use the in operator or so. (Above is
> equal to ((0, 'foo'), (1, 'bar')))
>
> --
> Ludvig Ericson
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to