Opened 2 years ago
Last modified 2 years ago
#34183 closed New feature
Add a ChoicesMeta.max_length property returning the max_length when data type supports len() — at Version 2
Reported by: | Coumes Quentin | Owned by: | Coumes Quentin |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 4.1 |
Severity: | Normal | Keywords: | choices, enums |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
It would be helpful for enums inheriting Choices
with a data type supporting len()
to be able to compute max_length
by themselves.
This would make the definition of field's max_length
easier as well as automatically create a new migration when deleting/adding members which would change the max_length
.
If the data type does not support len()
, it could raise TypeError
(same exception raise by len
) something like :
raise TypeError("Can only compute max_length on data type supporting len()")
I can do the patch if this feature does make sense to you.
Change History (2)
comment:1 by , 2 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 2 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.