Opened 2 years ago

Closed 2 years ago

#20298 closed Uncategorized (duplicate)

Forms - FloatField and IntegerField raise errors when a user enters space in textboxes.

Reported by: krishna@… Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When a user keys in few spaces in a FloatField or IntegerField. Django fails to treat them as empty and tries to convert them to float and int respectively, leading to an unnecessary validation error. Users need to define custom fields and custom clean methods currently to overcome this issue.

Stripping the value prior to conversion will solve the problem. I have submitted a pull reqhest here -
https://github.com/django/django/pull/1023

I have also attached the patch to this ticket.

Attachments (1)

fields.patch (844 bytes) - added by krishna@… 2 years ago.
Strips the value before checking for emptiness in case of FloatField and IntegerField

Download all attachments as: .zip

Change History (2)

Changed 2 years ago by krishna@…

Strips the value before checking for emptiness in case of FloatField and IntegerField

comment:1 Changed 2 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #18761 (which addresses the real issue, namely that Django's really inconsistent about where it strips and where it won't).

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