Django REST Framework 3.15
Released on March 15th, 2024 with 176 commits by 138 authors
Django 5.0 and Python 3.12 Support
The latest release now fully supports Django 5.0 and Python 3.12.Django Support
Minimum: Django 3.0
Latest: Django 5.0
Latest: Django 5.0
Python Support
Minimum: Python 3.6
Latest: Python 3.12
Latest: Python 3.12
Primary Support of UniqueConstraint
ModelSerializer now generates validators for UniqueConstraint, including both UniqueValidator and UniqueTogetherValidator.
Example
SimpleRouter Non-Regex Matching Support
By default the URLs created bySimpleRouter use regular expressions. This behavior can be modified by setting the use_regex_path argument to False when instantiating the router.
ZoneInfo as the Primary Source of Timezone Data
Dependency onpytz has been removed and deprecation warnings have been added. Django will provide ZoneInfo instances as long as USE_DEPRECATED_PYTZ is not enabled.
Example Migration
Align SearchFilter Behavior to Django Admin Search
Searches now may contain quoted phrases with spaces, where each phrase is considered as a single search term.Example
Simple Search
/api/articles/?search=djangoSearches for “django”
Quoted Phrases
/api/articles/?search="django rest"Searches for the exact phrase “django rest”
Multiple Terms
/api/articles/?search=django,pythonSearches for “django” OR “python”
Combined
/api/articles/?search="django rest",pythonSearches for “django rest” OR “python”
Browsable API Security Improvement
The browsable API now uses POST method instead of GET to perform logout. This prevents CSRF attacks that could force users to log out.Why this matters:Using GET for state-changing operations (like logout) is a security anti-pattern. An attacker could create a malicious link that logs users out when clicked. Using POST prevents this attack vector.
Other Fixes and Improvements
There are a number of fixes and minor improvements in this release:Core Features
Core Features
- jQuery upgraded to 3.7.1
- Use
stras default path converter - Document support for
http.HTTPMethodin@actiondecorator (Python 3.11+) - Partial serializers should not have required fields
- Propagate ‘default’ from model field to serializer field
- Allow to override
child.run_validationcall in ListSerializer
Bug Fixes
Bug Fixes
- Fix choices in ChoiceField to support IntEnum
- Fix SearchFilter rendering search field with invalid value
- Fix OpenAPI Schema yaml rendering for
timedelta - Fix NamespaceVersioning ignoring DEFAULT_VERSION on non-None namespaces
- Fixes BrowsableAPIRenderer for usage with ListSerializer
- Fix URLPathVersioning reverse fallback
Type Checking Support
Type Checking Support
- Allow Request, Response, Field, and GenericAPIView to be subscriptable
- This enables making classes generic for type checking
- Example:
GenericAPIView[MyModel]
Schema Generation
Schema Generation
- Fix pagination response schemas
- Removed usage of
field.choicesthat triggered full table load - Handle Nested Relation in SlugRelatedField when many=False
- Use PrimaryKeyRelatedField pkfield in OpenAPI
CSP Compatibility
CSP Compatibility
- Remove inline CSS
- Add CSP nonce where available
- Make browsable API compatible with strong CSP
- Avoid inline script execution for CSRF token injection
Complete Release Notes
See the release notes page for a complete listing of all changes.Upgrading
To upgrade to Django REST Framework 3.15:Community Growth
This release represents significant community involvement:176 Commits
Total commits in this release
138 Authors
Contributors to this release
Growing Ecosystem
Expanding third-party package support
Thank you to all the contributors who made this release possible! Your contributions, whether code, documentation, or community support, are invaluable to the Django REST Framework project.
Links
Full Changelog
View all changes on GitHub
PyPI Release
Download from PyPI
Migration Guide
PyTZ to ZoneInfo migration
Discussion Group
Join the community
