Django REST framework 3.14

Django 4.1 support

The latest release now fully supports Django 4.1, and drops support for Django 2.2.

Our requirements are now:

  • Python 3.6+
  • Django 4.1, 4.0, 3.2, 3.1, 3.0

raise_exception argument for is_valid is now keyword-only.

Calling serializer_instance.is_valid(True) is no longer acceptable syntax. If you'd like to use the raise_exception argument, you must use it as a keyword argument.

See Pull Request #7952 for more details.

ManyRelatedField supports returning the default when the source attribute doesn't exist.

Previously, if you used a serializer field with many=True with a dot notated source field that didn't exist, it would raise an AttributeError. Now it will return the default or be skipped depending on the other arguments.

See Pull Request #7574 for more details.

Make Open API get_reference public.

Returns a reference to the serializer component. This may be useful if you override get_schema().

Change semantic of OR of two permission classes.

When OR-ing two permissions, the request has to pass either class's has_permission() and has_object_permission().

Previously, both class's has_permission() was ignored when OR-ing two permissions together.

See Pull Request #7522 for more details.

Minor fixes and improvements

There are a number of minor fixes and improvements in this release. See the release notes page for a complete listing.


Deprecations

serializers.NullBooleanField

serializers.NullBooleanField was moved to pending deprecation in 3.12, and deprecated in 3.13. It has now been removed from the core framework.

Instead use serializers.BooleanField field and set allow_null=True which does the same thing.