DecimalField may "clean" itself and then raise an Exception
DecimalField may "clean" itself and then raise an Exception. In my case, it happens when I put a DecimalField in a django.newforms.Form class which will be used to "Edit" the model.
I suppose it would be necessary to check the type of parameter value like some of the other "Field" classes, such as DateField.
super(DecimalField, self).clean(value)
if not self.required and value in EMPTY_VALUES:
return None
value = value.strip() # raise AttributeError, 'Decimal' object has no attribute 'strip'
try:
value = Decimal(value)
Has patch: |
unset
|
Keywords: |
newforms added
|
Triage Stage: |
Unreviewed → Design decision needed
|
Keywords: |
sprintsept14 added
|
Owner: |
changed from nobody to Philippe Raoult
|
Triage Stage: |
Design decision needed → Accepted
|
Has patch: |
set
|
Status: |
new → assigned
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
There's no reason value would already be a decimal unless the data was a decimal in the first place. If you use a form with string input this will never happen. Maybe we should check in form inputs that the values are really strings and/or enforce this ?