mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-12-03 16:24:01 +03:00
feat: updated with changes requests
- typo fix - value test fix - import order fix
This commit is contained in:
parent
c831093ae5
commit
f6b53d8b26
|
|
@ -279,7 +279,7 @@ Corresponds to `django.db.models.fields.BigIntegerField`.
|
|||
|
||||
* `max_value` Validate that the number provided is no greater than this value.
|
||||
* `min_value` Validate that the number provided is no less than this value.
|
||||
* `coerce_to_string` Set to `True` if string values should be returned for the representation, or `False` if `BigInteger` objects should be returned. Defaults to the same value as the `COERCE_BIGINT_TO_STRING` settings key, which will be `True` unless overridden. If `BigInterger` objects are returned by the serializer, then the final output format will be determined by the renderer.
|
||||
* `coerce_to_string` Set to `True` if string values should be returned for the representation, or `False` if `BigInteger` objects should be returned. Defaults to the same value as the `COERCE_BIGINT_TO_STRING` settings key, which will be `True` unless overridden. If `BigInteger` objects are returned by the serializer, then the final output format will be determined by the renderer.
|
||||
|
||||
## FloatField
|
||||
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ Default: `True`
|
|||
|
||||
When returning biginteger objects in API representations that do not support numbers up to 2^64, it is best to return the value as a string. This avoids the loss of precision that occurs with biginteger implementations.
|
||||
|
||||
When set to `True`, the serializer `BigIntegerField` class will return strings instead of `BigInteger` objects. When set to `False`, serializers will return `BigInteger` objects, which the default JSON encoder will return as numbers.
|
||||
When set to `True`, the serializer `BigIntegerField` class (by default) will return strings instead of `BigInteger` objects. When set to `False`, serializers will return `BigInteger` objects, which the default JSON encoder will return as numbers.
|
||||
|
||||
Default: `False`
|
||||
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ from rest_framework.validators import (
|
|||
# This helps keep the separation between model fields, form fields, and
|
||||
# serializer fields more explicit.
|
||||
from rest_framework.fields import ( # NOQA # isort:skip
|
||||
BooleanField, CharField, ChoiceField, DateField, DateTimeField, DecimalField,
|
||||
BigIntegerField, BooleanField, CharField, ChoiceField, DateField, DateTimeField, DecimalField,
|
||||
DictField, DurationField, EmailField, Field, FileField, FilePathField, FloatField,
|
||||
HiddenField, HStoreField, IPAddressField, ImageField, IntegerField, JSONField,
|
||||
ListField, ModelField, MultipleChoiceField, ReadOnlyField, BigIntegerField,
|
||||
ListField, ModelField, MultipleChoiceField, ReadOnlyField,
|
||||
RegexField, SerializerMethodField, SlugField, TimeField, URLField, UUIDField,
|
||||
)
|
||||
from rest_framework.relations import ( # NOQA # isort:skip
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,9 @@ class TestCoercionBigIntegerField(TestCase):
|
|||
|
||||
def test_force_coerce_to_string(self):
|
||||
field = serializers.BigIntegerField(coerce_to_string=True)
|
||||
assert isinstance(field.to_representation(int('1')), str)
|
||||
value = field.to_representation(1)
|
||||
assert isinstance(value, str)
|
||||
assert value == "1"
|
||||
|
||||
|
||||
class TestFloatField(FieldValues):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user