Code

#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

Attachments (0)

Change History (5)

comment:1 Changed 11 months 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 11 months 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 11 months ago by dstufft

  • Needs documentation unset

comment:4 Changed 11 months ago by dstufft

  • Needs tests unset
  • Patch needs improvement unset

comment:5 Changed 11 months 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.