Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#1697 closed enhancement (fixed)

[patch] magic-removal: the choices keyword for Fields is restricted

Reported by: brantley Owned by: Adrian Holovaty
Component: Core (Other) Version: magic-removal
Severity: normal Keywords: validate choices
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The choices keyword is restricted to a list or tuple by the management.py, get_validation_errors(). It should instead allow anything that is iterable. For instance, a generator could then be used. I've attached a simple patch.

Attachments (1)

iterable.diff (849 bytes) - added by brantley 10 years ago.
patch

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by brantley

Attachment: iterable.diff added

patch

comment:1 Changed 10 years ago by Christopher Lenz <cmlenz@…>

Note that (I think) this will also allow strings, which will result in a different behavior than the developer would probably expect.

comment:2 Changed 10 years ago by brantley

Yes, it would be allowed by the validation, but would not work as the system will expect two-tuples. But I'm not sure if validate should check each item of the iterable or what.

comment:3 Changed 10 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [3094]) Fixed #1697 and #2095 -- Made 'choices' parameter accept any iterable

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