Skip to main content

Django REST Framework 3.16

Released on March 28th, 2025
At the Internet, on March 28th, 2025, we are happy to announce the release of Django REST framework 3.16.

Updated Django and Python Support

The latest release now fully supports Django 5.1 and the upcoming 5.2 LTS as well as Python 3.13.

Minimum Django Version

Django 4.2 LTS

Minimum Python Version

Python 3.9

Latest Django Support

Django 5.1, 5.2a1

Latest Python Support

Python 3.13
The current minimum versions are now Django 4.2 and Python 3.9. Python 3.8 support has been removed.

Django LoginRequiredMiddleware

The new LoginRequiredMiddleware introduced by Django 5.1 can now be used alongside Django REST Framework.
However, it is not honored for API views as equivalent behavior can be configured via DEFAULT_AUTHENTICATION_CLASSES. See our dedicated authentication section in the docs for more information.

Improved Support for UniqueConstraint

The generation of validators for UniqueConstraint has been improved to better support:

Nullable Fields

Better handling of nullable fields in unique constraints

Conditional Constraints

Support for constraints with conditions

Example

If you have a model with a conditional unique constraint:
from django.db import models

class Article(models.Model):
    title = models.CharField(max_length=200)
    slug = models.SlugField(null=True, blank=True)
    published = models.BooleanField(default=False)
    
    class Meta:
        constraints = [
            models.UniqueConstraint(
                fields=['slug'],
                condition=models.Q(published=True),
                name='unique_published_slug'
            )
        ]
The serializer will now correctly validate this constraint, respecting both the nullable fields and the condition.

Other Fixes and Improvements

There are a number of fixes and minor improvements in this release:
  • Updated links to use stable versions
  • Expanded docs on unique constraints
  • Added tutorial notes for HyperlinkedModelSerializer
  • Fixed broken links and typos
  • Updated GitHub Actions to Ubuntu 24.04
  • Updated test matrix for Django 5.2
  • Added pyupgrade to pre-commit hooks
  • Improved typing and test coverage
  • Fixed issues with AttributeError in properties
  • Fixed template context handling
  • Improved converter registration
  • Removed Python 3.8 support
  • Removed long deprecated code from request wrapper
  • Removed deprecated AutoSchema methods

Complete Release Notes

See the release notes page for a complete listing of all changes in version 3.16.

Upgrading

To upgrade to Django REST Framework 3.16:
pip install -U djangorestframework
Breaking Changes:
  • Python 3.8 is no longer supported
  • Improved UniqueConstraint validation may affect existing behavior with nullable fields
  • Some deprecated APIs have been removed

Contributors

This release includes contributions from many developers in the community:
New Contributors:
  • @araggohnxd, @mbeijen, @stefan6419846, @ren000thomas, @ulgens, @bukh-sal, @rezatn0934, @Rohit10jr, @kushibayev, @alihassancods, @kulikjak, @Natgho
Thank you to everyone who contributed to this release!

Full Changelog

View all changes on GitHub

PyPI Release

Download from PyPI

Documentation

Browse the documentation

Discussion Group

Join the community

Build docs developers (and LLMs) love