#26890 closed Bug (fixed)
forms.IntegerField does not support unicode numbers
Reported by: | Ben Youngblut | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.9 |
Severity: | Normal | Keywords: | IntegerField |
Cc: | jon.dufresne@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
A Japanese user on our site just tried to submit a form with u'50'
Python's int() function correctly handles it (as well as python's \d+ in regular expressions).
But in IntegerField's to_python the value is cast to a string before being run through a regex substitution to remove ".00000" .
I found a quick workaround I changed it to forms.FloatField and then I cast to an int in the clean_XXX function. (it is just for page number in my case so I don't care if it auto truncates/rounds)
Change History (4)
comment:1 by , 8 years ago
Cc: | added |
---|---|
Has patch: | set |
comment:2 by , 8 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|---|
Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
I believe this is just a matter of coercing the value to a text type instead of
str
to handle Python2.<https://github.com/django/django/pull/6908>