Opened 2 years ago

Closed 2 years ago

#20430 closed New feature (fixed)

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

Reported by: dstufft Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: charettes 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 2 years ago by dstufft

  • 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 2 years ago by charettes

  • Cc charettes added
  • Component changed from Uncategorized to Database layer (models, ORM)
  • Has patch set
  • Needs documentation set
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 years ago by dstufft

  • Needs documentation unset

comment:4 Changed 2 years ago by dstufft

  • Needs tests unset
  • Patch needs improvement unset

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

  • Resolution set to fixed
  • Status changed from new to closed

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