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 , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 12 years ago
Type: | Uncategorized → Bug |
---|
comment:4 by , 12 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
Reviewed, looks good to me.
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Added a pull request: https://github.com/django/django/pull/1105