Very strange issue here. I'm using the django-choices
module (v1.3), and defined a set of choices like so:
class BreaktimeChoices(DjangoChoices):
BREAKTIME_NONE = ChoiceItem(value=datetime.time(0,0), label=_('none'))
BREAKTIME_15_MIN = ChoiceItem(value=datetime.time(0,15), label=_('15 minutes'))
BREAKTIME_30_MIN = ChoiceItem(value=datetime.time(0,30), label=_('30 minutes'))
BREAKTIME_45_MIN = ChoiceItem(value=datetime.time(0,45), label=_('45 minutes'))
BREAKTIME_1_HOUR = ChoiceItem(value=datetime.time(1,0), label=_('1 hour'))
When I then put it into a form (with a select input) I notice that the labels are correct, but the value for BREAKTIME_NONE is 'none' (rather than the intended 00:00:00
). When printing out BreaktimeChoices.choices
I get this:
((<django.utils.functional.__proxy__ object at 0x7f995c306f50>, <django.utils.functional.__proxy__ object at 0x7f995c306f50>),
(datetime.time(0, 15), <django.utils.functional.__proxy__ object at 0x7f995c310f50>),
(datetime.time(0, 30), <django.utils.functional.__proxy__ object at 0x7f995c310bd0>),
(datetime.time(0, 45), <django.utils.functional.__proxy__ object at 0x7f995c310ed0>),
(datetime.time(1, 0), <django.utils.functional.__proxy__ object at 0x7f995c310fd0>))
As you can see, the datetime.time(0,0)
has been changed to a __proxy__
object (translatable string). What's more is, the the pointer address to this proxy is the same as the label
value for this choice. I use DjangoChoices
all over my project and haven't had this issue before. Has anyone else seen anything like it?