#14807 closed Uncategorized (fixed)
django.utils.formats localize_input inserts thousands_separator into boolean values
Reported by: | Klaas van Schelven | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | 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
formats.localize_input(True)
I'm working in an environment where I've localized all my forms (set localize=True on all fields). I also have the USE_THOUSAND_SEPARATOR = True.
This results the value attr in my booleanfield to be set to "T,rue" (Dutch) or "T.rue" (US).
The ultimate culprit is django.utils.formats localize_input
There is a check there like so:
if isinstance(value, (decimal.Decimal, float, int, long)):
which evaluates to True for Booleans (because booleans are ints, see "issubclass(bool, int)")
I do not currently have the time to provide tests etc. I do have a simple patch
Attachments (2)
Change History (15)
by , 14 years ago
comment:1 by , 14 years ago
Component: | Uncategorized → Internationalization |
---|---|
milestone: | → 1.3 |
Triage Stage: | Unreviewed → Accepted |
by , 14 years ago
comment:2 by , 14 years ago
- Added a patch, including a test this time. And still returning unicode for booleans (just not broken unicode)
- Turns out the problem also surfaces in more general settings (i.e. just printing booleans on screen).
comment:4 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 14 years ago
follow-up: 9 comment:7 by , 10 years ago
Easy pickings: | unset |
---|---|
Resolution: | fixed |
Severity: | → Normal |
Status: | closed → new |
Type: | → Uncategorized |
UI/UX: | unset |
When fixing this, input_localize was missed. My proposed solution (which is unfortunately not formatted as a pull request, nor does it have tests) is here:
https://github.com/vanschelven/django/commit/f0e39c83ec9174b8e5241caa6ba59b8e2e6deb66
Also copying my notes from that solution to justify reopening the issue:
6c53a81 only fixed localize(), but not localize_input()
It appears to me that this was simply an oversight at the time.
It seems that a new call-order for fields somewhere between Django 1.4
and Django 1.6 triggers triggers this bug again, but this time on the inputs
and only when rendering fields as_hidden.
comment:8 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I'll be better to open a new ticket rather than reopening one that's three years old where the original fix has already been released, thanks.