On Sun, Jun 12, 2011 at 11:13 AM, Meir Kriheli <[email protected]> wrote:

> Hi,
>
>
> Anyway I'll try to start using `flufl.enum` soon. One awesome application
>> that this could have is to make a Django `EnumField` (or `ChoiceField` or
>> whatever you want to call it) instead of the current ugly way of making an
>> `IntegerField` and defining `CHOICES` separately.
>>
>
> IMO it's not suitable for replacing Django's choices. Enums are used in
> Code/API, but aren't suitable for front-end/UI - where choices come into
> effect. The display value can, and will, contain spaces, unicode, minus
> signs,  etc, which are problematic in enums. Plus, the displayed values
> should be translatable.
>
> Enums can be used as the values in choices, which is the correct way to use
> them IMO in such a use case.e:g, taking into account the 1st example:
>
> from django.utils.translation import ugettext_lazy as _
>
> SHOULD_CHOICES = (
>     (YES, _('Yes')),
>     (NO, _('No')),
>     (MAYBE, _('Maybe')),
> )
>
> And later one can refer to them in the field's choices, model
> methods/views/etc.
>
> Cheers
> --
> Meir
>

Meir, if I were to make an `EnumField`, I would of course let people specify
a `verbose_name` for each selection. You could attach any kind of payload to
each of an enum's values.


Ram.
_______________________________________________
Python-il mailing list
[email protected]
http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il

לענות