#8556 closed (fixed)
models.CommaSeperatedIntegerField doesn't return a forms field of any use
| Reported by: | Alex Gaynor | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
CommaSeperatedIntegerField just returns a normal charfield, which obviously preforms no validation that it matches the purpose of the field.
Attachments (3)
Change History (11)
comment:1 by , 17 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
by , 17 years ago
| Attachment: | 74333.patch added |
|---|
comment:2 by , 17 years ago
| Has patch: | set |
|---|
comment:3 by , 17 years ago
| Needs tests: | set |
|---|
comment:4 by , 17 years ago
The regexp used in the patch is not completely right, it matches too many things:
>>> x = re.compile("^[\d,]+$") >>> >>> type(x.match("1,2,3")) <type '_sre.SRE_Match'> >>> type(x.match(",1,2,3")) <type '_sre.SRE_Match'> >>> type(x.match("1,2,3,")) <type '_sre.SRE_Match'> >>> type(x.match("1,,,,2,,,,,3,,,")) <type '_sre.SRE_Match'> >>> type(x.match("1.2")) <type 'NoneType'> >>> type(x.match(",,,,,")) <type '_sre.SRE_Match'>
I guess the problem is in "[\d,]" since the square brackets don't care about the order of the specified chars. Or maybe django should allow that strings?
comment:6 by , 17 years ago
| Needs tests: | unset |
|---|
comment:7 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Patch to return formfield using regex