mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 03:50:11 +03:00
The default empty value is now quantized according to the specified decimal_places argument.
This commit is contained in:
parent
e56ba33d1b
commit
3038e2b07f
|
@ -849,7 +849,6 @@ class DecimalField(WritableField):
|
|||
type_name = 'DecimalField'
|
||||
type_label = 'decimal'
|
||||
form_field_class = forms.DecimalField
|
||||
empty = Decimal('0')
|
||||
|
||||
default_error_messages = {
|
||||
'invalid': _('Enter a number.'),
|
||||
|
@ -863,6 +862,7 @@ class DecimalField(WritableField):
|
|||
def __init__(self, max_value=None, min_value=None, max_digits=None, decimal_places=None, *args, **kwargs):
|
||||
self.max_value, self.min_value = max_value, min_value
|
||||
self.max_digits, self.decimal_places = max_digits, decimal_places
|
||||
self.empty = Decimal('0').qauntize(Decimal('.%s1' % ('0' * self.decimal_places)))
|
||||
super(DecimalField, self).__init__(*args, **kwargs)
|
||||
|
||||
if max_value is not None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user