Add a compatibility setting for ListSerializer error formats - #10027
Merged
auvipy merged 4 commits intoSep 3, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a REST framework setting to control the ListSerializer (many=True) per-item validation error format, restoring the legacy list-based structure as the default while allowing opt-in to the newer dict-based format.
Changes:
- Introduces
REST_FRAMEWORK['LIST_SERIALIZER_ERRORS_AS_DICT'](defaultFalse) and updatesListSerializer.to_internal_value()to emit legacy list-form errors (with a deprecation warning) unless the dict format is enabled. - Updates and expands serializer list-related tests to cover both formats and warning behavior.
- Documents the new setting and the deprecation/transition plan in the settings and serializers guides.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_serializer.py | Adjusts a regression test to expect the new deprecation warning alongside the raised validation error. |
| tests/test_serializer_lists.py | Adds coverage for default legacy list errors, opt-in dict errors, and explicit legacy setting behavior. |
| tests/test_serializer_bulk_update.py | Updates expected bulk many=True error shapes to match the restored legacy list format and asserts warnings. |
| rest_framework/settings.py | Adds the new LIST_SERIALIZER_ERRORS_AS_DICT default setting. |
| rest_framework/serializers.py | Implements conditional legacy-vs-dict error formatting and emits a deprecation warning for the legacy default. |
| rest_framework/init.py | Adds RemovedInDRF320Warning warning class used for the deprecation signal. |
| docs/api-guide/settings.md | Documents the new LIST_SERIALIZER_ERRORS_AS_DICT setting and its behavior. |
| docs/api-guide/serializers.md | Updates serializer error-format documentation to note deprecation and explain enabling dict-based errors. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
browniebroke
reviewed
Sep 1, 2026
browniebroke
reviewed
Sep 1, 2026
auvipy
approved these changes
Sep 3, 2026
auvipy
approved these changes
Sep 3, 2026
Collaborator
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.
Description
Follow-up to #9837 and #10018.
This adds
LIST_SERIALIZER_ERRORS_AS_DICT. It defaults toTrue, preserving the dictionary format introduced in 3.18.0.Projects can set it to
Falseto temporarily restore the old list-based format while migrating. This emitsRemovedInDRF320Warning, and the list format will be removed in 3.20.