Opened 18 years ago
Closed 17 years ago
#3841 closed (worksforme)
ManyToMany field can be empty even if required=True
Reported by: | anonymous | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ManyToMany field | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
A ManyToMany field defined as required=True is not considered as empty if no choice has been selected in the form.
It seems that the only values to be considered as empty are only None and ", as defined in the file newforms/fields.py :
EMPTY_VALUES = (None, ")
Unfortunately, [] is not in this list.
Adding the value [] in the list EMPTY_VALUES seems to fix the issue, please can you confirm ?
Thanks.
Change History (2)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 17 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I assume you meant
MultipleChoiceField
and notManyToMany
field (MultipleChoiceField
is the default form field used forManyToMany
model fields). Things seem to work for me when no choice is selected in the form:Please post back with some examples if you are still experiencing this problem.