Opened 12 years ago

Closed 12 years ago

#20430 closed New feature (fixed)

Enable Any iterable of two item iterables to be used for choices

Reported by: Donald Stufft Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Simon Charette Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently the validation checks in django.core.management.validation check explicitly for list or tuple. This is less than ideal and flies in the face of duck typing. We should enable any iterable of two item iterables to be used for the choices field. This makes it pretty easy to use the upcoming Python 3.4 enums as a choices= (see: https://gist.github.com/dstufft/5600529#file-models-py-L61-L67).

There's a pull request for this here https://github.com/django/django/pull/1081

Change History (5)

comment:1 by Donald Stufft, 12 years ago

@charettes has mentioned that I should likely write tests ensuring that iterables remain working.

comment:2 by Simon Charette, 12 years ago

Cc: Simon Charette added
Component: UncategorizedDatabase layer (models, ORM)
Has patch: set
Needs documentation: set
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:3 by Donald Stufft, 12 years ago

Needs documentation: unset

comment:4 by Donald Stufft, 12 years ago

Needs tests: unset
Patch needs improvement: unset

comment:5 by Donald Stufft <donald@…>, 12 years ago

Resolution: fixed
Status: newclosed

In a19e9d80ffa10f8da43addcaa4ddd440beee8a4d:

Fixed #20430 - Enable iterable of iterables for model choices

Allows for any iterable, not just lists or tuples, to be used as
the inner item for a list of choices in a model.

Note: See TracTickets for help on using tickets.
Back to Top