Ordering doesn't work when setting order kwargs to 0
Closed this issue · 1 comments
RobinRamael commented
The constructor for ChoiceItem
checks the order
kwarg for truthiness instead for wether it's None
, which puts that ChoiceItem
in the wrong place in the ordering.
e.g.
In [5]: class SomeChoices(DjangoChoices):
...: foo = C(order=0)
...: bar = C(order=1)
...: baz = C(order=2)
...:
In [6]: SomeChoices.choices
Out[6]: (('bar', 'bar'), ('baz', 'baz'), ('foo', 'foo'))
While we'd expect the order be the same as the class definition. This behavior is not mentioned in the docs.
sergei-maertens commented
input from Slack by Robin:
the bug is in the ChoiceItem constructor, it does
if not ordering: orderin= some default
, instead ofif ordering is None