mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
Convert any types (strings usualy) to integer
This commit is contained in:
parent
711fb9761c
commit
4be4dccc91
|
@ -777,6 +777,12 @@ class IntegerField(WritableField):
|
|||
raise ValidationError(self.error_messages['invalid'])
|
||||
return value
|
||||
|
||||
def to_native(self, value):
|
||||
value = super(IntegerField, self).to_native(value)
|
||||
if value is None:
|
||||
return value
|
||||
return int(value)
|
||||
|
||||
|
||||
class FloatField(WritableField):
|
||||
type_name = 'FloatField'
|
||||
|
|
Loading…
Reference in New Issue
Block a user