Add optional support to serialize BigInteger to string#9775
Merged
auvipy merged 8 commits intoencode:mainfrom Dec 2, 2025
Merged
Add optional support to serialize BigInteger to string#9775auvipy merged 8 commits intoencode:mainfrom
BigInteger to string#9775auvipy merged 8 commits intoencode:mainfrom
Conversation
… can have string api representation
Contributor
Author
|
Any news? |
peterthomassen
requested changes
Oct 9, 2025
- typo fix - value test fix - import order fix
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new BigIntegerField serializer field to properly handle Django's BigIntegerField and BigAutoField model fields, addressing issue #9733. Previously, these fields were incorrectly mapped to the standard IntegerField serializer.
Key Changes:
- Introduces
BigIntegerFieldclass that extendsIntegerFieldwith optional string coercion for large integers - Adds
COERCE_BIGINT_TO_STRINGsetting (default:False) to control output format - Updates model field mappings to use
BigIntegerFieldforBigIntegerFieldandBigAutoField
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| rest_framework/fields.py | Implements new BigIntegerField class with coerce_to_string parameter and custom error messages |
| rest_framework/serializers.py | Imports BigIntegerField and updates serializer_field_mapping to map Django's BigIntegerField and BigAutoField to the new field type |
| rest_framework/settings.py | Adds COERCE_BIGINT_TO_STRING configuration setting with default value of False |
| docs/api-guide/fields.md | Documents the new BigIntegerField with its signature and parameters |
| docs/api-guide/settings.md | Documents the COERCE_BIGINT_TO_STRING setting and its behavior |
| tests/test_fields.py | Adds comprehensive test cases for BigIntegerField including validation, min/max constraints, and string coercion |
| tests/test_model_serializer.py | Updates expected serializer representation test to expect BigIntegerField instead of IntegerField |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
peterthomassen
approved these changes
Nov 13, 2025
Collaborator
peterthomassen
left a comment
There was a problem hiding this comment.
lgtm! Thank you for this contribution.
auvipy
approved these changes
Dec 2, 2025
browniebroke
approved these changes
Dec 2, 2025
Merged
BigInteger to string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixing Bigint coerce to string missing
Creates a new type
BigIntegerFieldto mapdjango.models.BigIntegerFieldand solve the problemFix #9733