Skip to content

Commit f6b53d8

Browse files
committed
feat: updated with changes requests
- typo fix - value test fix - import order fix
1 parent c831093 commit f6b53d8

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

docs/api-guide/fields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ Corresponds to `django.db.models.fields.BigIntegerField`.
279279

280280
* `max_value` Validate that the number provided is no greater than this value.
281281
* `min_value` Validate that the number provided is no less than this value.
282-
* `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.
282+
* `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.
283283

284284
## FloatField
285285

docs/api-guide/settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ Default: `True`
375375

376376
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.
377377

378-
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.
378+
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.
379379

380380
Default: `False`
381381

rest_framework/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
# This helps keep the separation between model fields, form fields, and
5454
# serializer fields more explicit.
5555
from rest_framework.fields import ( # NOQA # isort:skip
56-
BooleanField, CharField, ChoiceField, DateField, DateTimeField, DecimalField,
56+
BigIntegerField, BooleanField, CharField, ChoiceField, DateField, DateTimeField, DecimalField,
5757
DictField, DurationField, EmailField, Field, FileField, FilePathField, FloatField,
5858
HiddenField, HStoreField, IPAddressField, ImageField, IntegerField, JSONField,
59-
ListField, ModelField, MultipleChoiceField, ReadOnlyField, BigIntegerField,
59+
ListField, ModelField, MultipleChoiceField, ReadOnlyField,
6060
RegexField, SerializerMethodField, SlugField, TimeField, URLField, UUIDField,
6161
)
6262
from rest_framework.relations import ( # NOQA # isort:skip

tests/test_fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,9 @@ class TestCoercionBigIntegerField(TestCase):
11581158

11591159
def test_force_coerce_to_string(self):
11601160
field = serializers.BigIntegerField(coerce_to_string=True)
1161-
assert isinstance(field.to_representation(int('1')), str)
1161+
value = field.to_representation(1)
1162+
assert isinstance(value, str)
1163+
assert value == "1"
11621164

11631165

11641166
class TestFloatField(FieldValues):

0 commit comments

Comments
 (0)