Opened 12 years ago

Closed 12 years ago

#20440 closed Bug (fixed)

forms.CharField should return an exception if max_length is not an integer

Reported by: Tome Cvitan Owned by: Tome Cvitan
Component: Forms Version: dev
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

In models.CharField you can define a verbose_name by placing a string as the first parameter, i.e. models.CharField("foo")

If you by mistake happen to define a forms.CharField with the same pattern, i.e. forms.CharField("foo"), there will be no error message and the input field will be rendered with the attribute maxlength="foo" which is invalid.

The proposed solution is to attempt to cast non-empty max_length and min_length values to an int in the init method of CharField.

Change History (5)

comment:1 by Tome Cvitan, 12 years ago

Owner: changed from nobody to Tome Cvitan
Status: newassigned

comment:2 by Tome Cvitan, 12 years ago

Has patch: set
Version 0, edited 12 years ago by Tome Cvitan (next)

comment:3 by Tome Cvitan, 12 years ago

Type: UncategorizedBug

comment:4 by senko, 12 years ago

Triage Stage: UnreviewedReady for checkin

Reviewed, looks good to me.

comment:5 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In caf56ad1743778bad8af6b51b08f5baa342d4cd2:

Fixed #20440 -- Ensured CharField's max_length/min_length are integers

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