#13631 closed (fixed)
IntegerField has no attributes max_value and min_value (1.2 regression)
Reported by: | Miloslav Pojman | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.2 |
Severity: | Keywords: | regression | |
Cc: | Greg Wogan-Browne | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Attributes min_value and max_value are no longer set on IntegerField, FloatField and DecimalField in Django 1.2.
Note these attributes are documented: http://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.IntegerField.max_value.
I'm using them to generate some javascript validation.
Attachments (1)
Change History (8)
comment:1 by , 15 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
Triage Stage: | Accepted → Design decision needed |
---|
This would probably actually fit better in DDN.
comment:3 by , 15 years ago
This can be easily fixed by setting a field attribute in addition to adding a validator - similar to current CharField implementation.
The problem with this approach is that attribute value and validator can become easily inconsistent. Therefore from my point of view the design decision needed here is whether form field attributes are mutable or not. For example: Can be CharField min_length set in form init method?
I am attaching more tests.
by , 15 years ago
comment:4 by , 14 years ago
Cc: | added |
---|---|
Keywords: | regression added |
comment:5 by , 14 years ago
Triage Stage: | Design decision needed → Accepted |
---|
The documentation says "Takes two optional arguments for validation". It makes no guarantees about the field having an attribute. However, it's trivial to fix, and other attributes (e.g., max_digits on DecimalField, max_length on CharField), so it's worth doing.
comment:6 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I haven't seen the old code, but it seems IntegerField now does min/max using django.core.validators. The fields are indeed not set in the code.
I think the documentation is not very clear on whether or not these fields should exist.
So, either the fields should be added, or the documentation should be clarified so that it doesn't suggests these fields being there.
I don't see an easy alternative to get them from the field instance.