Opened 3 years ago

Closed 3 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: master
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 Changed 3 years ago by Donald Stufft

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

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

comment:2 Changed 3 years ago by Simon Charette

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 Changed 3 years ago by Donald Stufft

Needs documentation: unset

comment:4 Changed 3 years ago by Donald Stufft

Needs tests: unset
Patch needs improvement: unset

comment:5 Changed 3 years ago by Donald Stufft <donald@…>

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