Opened 7 years ago
Closed 7 years ago
#28467 closed Cleanup/optimization (needsinfo)
Missing real MultiValueField - MultiValueField is actually a MultiField
Reported by: | Sven R. Kunze | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.11 |
Severity: | Normal | Keywords: | MultiValueField MultiField |
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 )
Hey everybody,
I need a MultiValueField because I have a field which can carry 10 integers, or another field with can carry 20 dates. The count of values is not fixed, just examples here.
So, I was quite enthusiastic to see that Django features a MultiValueField. Unfortunately, it turned out to be a MultiField (a field encompassing multiple fields) but not a real MultiValueField (a field encompassing multiple values).
Would it be possible to
1) rename MultiValueField
2) add a real MultiValueField which just wraps an arbitrary form field and produces a field which could valid more than one input values (not fixed)
?
Regards,
Sven
PS: No, I don't need a MultipeChoiceField because choices comprises of all integers or all dates, so choices would be rather huge (infinite). Same for TypedMultipeChoiceField.
Change History (4)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:3 by , 7 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → new |
It has nothing to do with foreign keys. Let me give you an example. HTML features multi value fields like this:
<form> <input name="a" value="123" /> <input name="a" value="456" /> <input name="a" value="789" /> </form>
How do I validate the integer field 'a' with Django?
comment:4 by , 7 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
I'd still ask that you draft a patch to show exactly how this field would work and then write to the DevelopersMailingList to see if there's consensus that this should be a part of Django.
I think that usually a foreign key (and therefore, inline formsets) would be used for a one to many relation.
Renaming
MultiValueField
would likely cause more disruption than its worth.It's not clear to me how the field that you propose would be implemented. Feel free to implement something and share it to the DevelopersMailingList. If it becomes so popular that 80% of Django projects are using it, perhaps we would consider adding it to Django, however, I think the use case probably doesn't merit it. There are plenty of third-party apps providing useful form fields that don't need to be a part of Django itself.