#34388: Added support for direct usage of Choices classes on model fields -------------------------------------+------------------------------------- Reporter: T. Franzel | Owner: nobody Type: New feature | Status: closed Component: Database layer | Version: dev (models, ORM) | Severity: Normal | Resolution: wontfix Keywords: | Triage Stage: | Unreviewed Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Nick Pope): I implemented much of the `Choices` stuff on the back of an initial version by Shai. I'm quite sympathetic to allowing this change as it would be cleaner. The main reason we didn't was to not increase the scope of acceptable types - notably we didn't want to allow arbitrary enums - `Choices` handles a bunch of things around display values and provides some convenience properties. Using `.choices` was a way of sticking with the existing list of 2-tuples. We also didn't need to make sure that something didn't break elsewhere, but adding `.choices` is crufty in a way. If we do this, we should only allow `Choices` subclasses, not generic enums. I don't think it'd add to much complexity to typing stuff, caveat the issues around supporting multiple versions in one set of stubs. Also, given it wouldn't be used internally, we'd need to comment in the code carefully to prevent regression and it'd be semi-public API, but undocumented. I'm not sure we should have this be something that is trumpeted about though - do we want this to be widely used? There is precedent for those sort of thing in private API to not break things - `ConnectionHandler.databases` IIRC - but does this justify adding something new? 🤔 -- Ticket URL: <https://code.djangoproject.com/ticket/34388#comment:7> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/01070186cc07ecda-8df89ef6-0419-4c0f-b027-6078076c8480-000000%40eu-central-1.amazonses.com.