Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#28303 closed Bug (fixed)

IntegerField & NumberInput widget localize max_value when rendering form field

Reported by: Richard Owen Owned by: nobody
Component: Forms Version: 1.11
Severity: Release blocker 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

This issue is a change / regression in Django 1.11. It works correctly with Django 1.10. Tested on Django 1.11.2 and Python 2.7.13.

Reproduction Steps

  1. Enable the following settings:
USE_L10N = True
USE_THOUSAND_SEPARATOR = True
  1. Create a form with an IntegerField with a large max_value set:
class TestForm(forms.Form):
    integer_field = forms.IntegerField(max_value=999999)

Expected Result

Form is rendered as

<input type="number" name="integer_field" max="999999" required id="id_integer_field" />

Actual Result

Form is rendered as

<input type="number" name="integer_field" max="999,999" required id="id_integer_field" />

Note the comma separator in the max attribute on the input.

Internet Explorer 11 treats this field as having a max attribute of 999. So entering a value of 1000 in the field prevents the user from submitting the form.

Change History (4)

comment:1 Changed 2 years ago by Tim Graham

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

581879a510e58841e5780a5d1fdb4995733d2036 fixed a similar issue and might be a useful template for developing a patch.

comment:2 Changed 2 years ago by Tim Graham

Has patch: set

comment:3 Changed 2 years ago by GitHub <noreply@…>

Resolution: fixed
Status: newclosed

In 3b050fd:

Fixed #28303 -- Prevented localization of attribute values in the DTL attrs.html widget template.

comment:4 Changed 2 years ago by Tim Graham <timograham@…>

In f0ec88fb:

[1.11.x] Fixed #28303 -- Prevented localization of attribute values in the DTL attrs.html widget template.

Backport of 3b050fd0d0b8dbf499bdb44ce12fa926298c0bd0 from master

Note: See TracTickets for help on using tickets.
Back to Top