Opened 9 years ago

Closed 9 years ago

#2182 closed defect (invalid)

IntegerField gets bogus validator_list from parent class

Reported by: ubernostrum Owned by: jacob
Component: Documentation Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


django.forms.IntegerField is a subclass of django.forms.TextField; this is all well and good, and makes sense, except for the last line of IntegerField's __init__, which calls TextField's __init__; this adds 'hasNoNewlines' and 'isValidLength' to the IntegerField's validator_list. This will end up causing exceptions during validation because integers aren't iterable and don't have a length.

The solution to this looks like it will involve changing IntegerField's __init__ to supply all the needed attributes without calling TextField's __init__, or possibly just sticking with what we have and culling the bad validators from validator_list after the fact,

Change History (3)

comment:1 Changed 9 years ago by ubernostrum

  • Component changed from Validators to Documentation
  • Owner changed from adrian to jacob
  • priority changed from high to normal
  • Severity changed from blocker to normal

Actually, I just realized the problem here: since we expect manipulators to be dealing with input from HTML forms, which will always be strings, this is actually correct. It just means that to programmatically use manipulators you have to call str on these fields to make sure the manipulator gets what it expects. My bad.

However, that makes this a documentation bug, because the manipulator docs don't mention this.

comment:2 Changed 9 years ago by ubernostrum

And while I'm mentioning documentation bugs, it'd be nice for the manipulator docs to mention that if you only show a subset of the model's fields on an HTML page, you'll need to populate any other required fields in new_data manually in your view before you try to validate or save.

comment:3 Changed 9 years ago by Gary Wilson <gary.wilson@…>

  • Resolution set to invalid
  • Status changed from new to closed

There is a note in the Validotors section of the Forms, fields, and manipulators documentation that states "At the point validators are called all data will still be strings (as do_html2python hasn't been called yet)."

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